forms.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:hawkpost 作者: whitesmith 项目源码 文件源码
def clean_message(self):
        # Quick check if the message really came encrypted
        message = self.cleaned_data.get("message")
        lines = message.split("\r\n")

        if getsizeof(message) > MAX_MESSAGE_SIZE:
            self.add_error(
                "message",
                _('The message or file exceeds your allowed size limit.')
            )

        begin = "-----BEGIN PGP MESSAGE-----"
        end = "-----END PGP MESSAGE-----"

        try:
            if lines[0] != begin or lines[-1] != end:
                self.add_error("message", _('Invalid PGP message'))
        except IndexError:
            self.add_error("message", _('Invalid PGP message'))
        return message
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号