示例#1
0
    def unmarshall(self, entry, value):
        """See `IFieldMarshaller`.

        Return the value as is.
        """

        if (value is not None and getUtility(ILaunchBag).user is None):
            return obfuscate_email(value)
        return value
示例#2
0
    def strip_email(self):
        """Strip out things that may be email.

        This is a variation on obfuscate_email for when we are generating a
        snipped for page metadata: we don't want to waste space spelling out
        "<email address hidden>", and we do want to strip addresses even for
        logged-in users in case they use the summary in a sharing tool.
        """
        return obfuscate_email(self._stringtoformat, replacement="...")
    def strip_email(self):
        """Strip out things that may be email.

        This is a variation on obfuscate_email for when we are generating a
        snipped for page metadata: we don't want to waste space spelling out
        "<email address hidden>", and we do want to strip addresses even for
        logged-in users in case they use the summary in a sharing tool.
        """
        return obfuscate_email(self._stringtoformat, replacement="...")
示例#4
0
    def unmarshall(self, entry, value):
        """See `IFieldMarshaller`.

        Return the value as is.
        """

        if (value is not None and getUtility(ILaunchBag).user is None):
            return obfuscate_email(value)
        return value
示例#5
0
    def obfuscate_email(self):
        """Obfuscate an email address if there's no authenticated user.

        The email address is obfuscated as <email address hidden>.

        This formatter is intended to hide possible email addresses from
        unauthenticated users who view this text on the Web. Run this before
        the text is converted to html because text-to-html and email-to-html
        will insert markup into the address. eg.
        foo/fmt:obfuscate-email/fmt:email-to-html

        The pattern used to identify an email address is not 2822. It strives
        to match any possible email address embedded in the text. For example,
        mailto:[email protected] and http://person:[email protected] both
        match, though the http match is in fact not an email address.
        """
        if getUtility(ILaunchBag).user is not None:
            return self._stringtoformat
        return obfuscate_email(self._stringtoformat)
    def obfuscate_email(self):
        """Obfuscate an email address if there's no authenticated user.

        The email address is obfuscated as <email address hidden>.

        This formatter is intended to hide possible email addresses from
        unauthenticated users who view this text on the Web. Run this before
        the text is converted to html because text-to-html and email-to-html
        will insert markup into the address. eg.
        foo/fmt:obfuscate-email/fmt:email-to-html

        The pattern used to identify an email address is not 2822. It strives
        to match any possible email address embedded in the text. For example,
        mailto:[email protected] and http://person:[email protected] both
        match, though the http match is in fact not an email address.
        """
        if getUtility(ILaunchBag).user is not None:
            return self._stringtoformat
        return obfuscate_email(self._stringtoformat)
示例#7
0
 def getBody(self):
     """The body of the HTTP response is the message body."""
     text = self.context.body_text
     if self.user is None:
         text = obfuscate_email(text)
     return text
示例#8
0
 def getBody(self):
     """The body of the HTTP response is the message body."""
     text = self.context.body_text
     if self.user is None:
         text = obfuscate_email(text)
     return text