예제 #1
0
    def validate_ticket(self, req, ticket):
        """Validate a ticket after it's been populated from user input.

        Must return a list of `(field, message)` tuples, one for each problem
        detected. `field` can be `None` to indicate an overall problem with the
        ticket. Therefore, a return value of `[]` means everything is OK."""

        mail = parseaddr(ticket['reporter'])[1]
        if self.reject_emails_re.match(mail.lower()):
            return [('reporter', '"%s" isn\'t acceptable as e-mail address' % (mail))]
        elif req.authname and req.authname != 'anonymous' or rfc822.valid(ticket['reporter']):
            return []
        else:
            return [(None, 'Either use a valid reporter address or log in.'),
                    ('reporter', \
                'should contain a valid e-mail address. E.g. "Nickname <*****@*****.**>"')]
예제 #2
0
    def validate_ticket(self, req, ticket):
        """Validate a ticket after it's been populated from user input.

        Must return a list of `(field, message)` tuples, one for each problem
        detected. `field` can be `None` to indicate an overall problem with the
        ticket. Therefore, a return value of `[]` means everything is OK."""

        mail = parseaddr(ticket['reporter'])[1]
        if self.reject_emails_re.match(mail.lower()):
            return [('reporter',
                     '"%s" isn\'t acceptable as e-mail address' % (mail))]
        elif req.authname and req.authname != 'anonymous' or rfc822.valid(
                ticket['reporter']):
            return []
        else:
            return [(None, 'Either use a valid reporter address or log in.'),
                    ('reporter', \
                'should contain a valid e-mail address. E.g. "Nickname <*****@*****.**>"')]
예제 #3
0
    def test(self, req, author, content, ip):
        points = -abs(self.karma_points)

        if req.authname and req.authname != 'anonymous':
           self.log.debug("Authenticated user, skipping...")
           return

        # Split up author into name and email, if possible
        author = author.encode('utf-8')
        author_name, author_email = parseaddr(author)
        self.log.debug("Author name is [%s] and e-mail is [%s]", author_name, author_email)

        if not author_email:
           return points, 'No e-mail found'
        elif self.reject_emails_re.match(author_email.lower()):
           return points, 'Example e-mail detected'
        elif rfc822.valid(author_email):
           points = abs(self.karma_points)
           return points, 'Valid e-mail found'
        else:
           return points, 'No valid RFC822 e-mail address found in reporter field'
예제 #4
0
    def test(self, req, author, content, ip):
        points = -abs(self.karma_points)

        if req.authname and req.authname != 'anonymous':
            self.log.debug("Authenticated user, skipping...")
            return

        # Split up author into name and email, if possible
        author = author.encode('utf-8')
        author_name, author_email = parseaddr(author)
        self.log.debug("Author name is [%s] and e-mail is [%s]", author_name,
                       author_email)

        if not author_email:
            return points, 'No e-mail found'
        elif self.reject_emails_re.match(author_email.lower()):
            return points, 'Example e-mail detected'
        elif rfc822.valid(author_email):
            points = abs(self.karma_points)
            return points, 'Valid e-mail found'
        else:
            return points, 'No valid RFC822 e-mail address found in reporter field'