How to use the pyisemail.diagnosis.DeprecatedDiagnosis function in pyIsEmail

To help you get started, we’ve selected a few pyIsEmail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michaelherold / pyIsEmail / tests / validators / __init__.py View on Github external
elif tag == "DNSWARN":
        d_class = DNSDiagnosis
    elif tag == "VALID":
        d_class = ValidDiagnosis
    elif tag == "RFC5321":
        d_class = RFC5321Diagnosis
    elif tag == "VALID":
        d_class = ValidDiagnosis
    elif tag == "RFC5321":
        d_class = RFC5321Diagnosis
    elif tag == "RFC5322":
        d_class = RFC5322Diagnosis
    elif tag == "CFWS":
        d_class = CFWSDiagnosis
    elif tag == "DEPREC":
        d_class = DeprecatedDiagnosis
    else:
        d_class = ""

    return d_class
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
#
                    #   obs-FWS         =   1*([CRLF] WSP)

                    if token_prior == Char.CR:
                        if token == Char.CR:
                            # Fatal error
                            return_status.append(
                                InvalidDiagnosis('FWS_CRLF_X2'))
                            break

                        if crlf_count != -1:
                            crlf_count += 1
                            if crlf_count > 1:
                                # Multiple folds = obsolete FWS
                                return_status.append(
                                    DeprecatedDiagnosis('FWS'))
                        else:
                            crlf_count = 1

                    # Skip simulates the use of ++ operator if the latter
                    # check doesn't short-circuit
                    if token == Char.CR:
                        skip = True

                        if (i+1 == raw_length or
                                to_char(address[i+1]) != Char.LF):
                            return_status.append(InvalidDiagnosis('CR_NO_LF'))
                            break
                    elif token in [Char.SP, Char.HTAB]:
                        pass
                    else:
                        if token_prior == Char.CR:
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
#   obs-NO-WS-CTL   =   %d1-8 /      ; US-ASCII control
                        #                       %d11 /       ; characters that
                        #                       %d12 /       ; do not include
                        #                       %d14-31 /    ; the CR, LF, and
                        #                                    ; white space
                        #                                    ; characters

                        o = ord(token)

                        if o > 127 or o == 0 or o == 10:
                            # Fatal error
                            return_status.append(
                                InvalidDiagnosis('EXPECTING_CTEXT'))
                            break
                        elif o < 32 or o == 127:
                            return_status.append(DeprecatedDiagnosis('CTEXT'))

                # -------------------------------------------------------
                # Folding White Space (FWS)
                # -------------------------------------------------------
                elif context == Context.FWS:
                    # http://tools.ietf.org/html/rfc5322#section-3.2.2
                    #   FWS             =   ([*WSP CRLF] 1*WSP) /  obs-FWS
                    #                       ; Folding white space
                    #
                    # But note the erratum:
                    # http://www.rfc-editor.org/errata_search.php?rfc=5322&eid=1908
                    #   In the obsolete syntax, any amount of folding white
                    #   space MAY be inserted where the obs-FWS rule is
                    #   allowed. This creates the possibility of having two
                    #   consecutive "folds" in a line, and therefore the
                    #   possibility that a line which makes up a folded header
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
RFC5322Diagnosis('LOCAL_TOOLONG'))
                        # http://tools.ietf.org/html/rfc5322#section-3.4.1
                        #   Comments and folding white space
                        #   SHOULD NOT be used around the "@" in the addr-spec.
                        #
                        # http://tools.ietf.org/html/rfc2119
                        # 4. SHOULD NOT   This phrase, or the phrase "NOT
                        #    RECOMMENDED" mean that there may exist valid
                        #    reasons in particular circumstances when the
                        #    particular behavior is acceptable or even useful,
                        #    but the full implications should be understood and
                        #    the case carefully weighed before implementing any
                        #    behavior described with this label.
                        elif context_prior in [Context.COMMENT, Context.FWS]:
                            return_status.append(
                                DeprecatedDiagnosis('CFWS_NEAR_AT'))

                        # Clear everything down for the domain parsing
                        context = Context.DOMAIN
                        context_stack = []
                        element_count = 0
                        element_len = 0
                        # CFWS can only appear at the end of the element
                        end_or_die = False
                    # atext
                    else:
                        # http://tools.ietf.org/html/rfc5322#section-3.2.3
                        #    atext  =  ALPHA / DIGIT /  ; Printable US-ASCII
                        #              "!" / "#" /      ; characters not
                        #              "$" / "%" /      ; including specials.
                        #              "&" / "'" /      ; Used for atoms.
                        #              "*" / "+" /
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
end_or_die = False
                            element_len = 0
                            element_count += 1
                            parse_data[Context.LOCALPART] += token
                            atom_list[Context.LOCALPART].append('')
                    elif token == Char.DQUOTE:
                        if element_len == 0:
                            # The entire local-part can be a quoted string for
                            # RFC 5321. If it's just one atom that is quoted
                            # then it's an RFC 5322 obsolete form
                            if element_count == 0:
                                return_status.append(
                                    RFC5321Diagnosis('QUOTEDSTRING'))
                            else:
                                return_status.append(
                                    DeprecatedDiagnosis('LOCALPART'))

                            parse_data[Context.LOCALPART] += token
                            atom_list[Context.LOCALPART][element_count] += token
                            element_len += 1
                            end_or_die = True
                            context_stack.append(context)
                            context = Context.QUOTEDSTRING
                        else:
                            # Fatal error
                            return_status.append(
                                InvalidDiagnosis('EXPECTING_ATEXT'))
                    # Folding White Space (FWS)
                    elif token in [Char.CR, Char.SP, Char.HTAB]:
                        # Skip simulates the use of ++ operator if the latter
                        # check doesn't short-circuit
                        if token == Char.CR:
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
# validator. The conclusion I have reached is this:
                    # "addressing information" must comply with RFC 5321 (and
                    # in turn RFC 1035), anything that is "semantically
                    # invisible" must comply only with RFC 5322.

                    # Comment
                    if token == Char.OPENPARENTHESIS:
                        if element_len == 0:
                            # Comments at the start of the domain are
                            # deprecated in the text
                            # Comments at the start of a subdomain are
                            # obs-domain
                            # (http://tools.ietf.org/html/rfc5322#section-3.4.1)
                            if element_count == 0:
                                return_status.append(
                                    DeprecatedDiagnosis('CFWS_NEAR_AT'))
                            else:
                                return_status.append(
                                    DeprecatedDiagnosis('COMMENT'))
                        else:
                            return_status.append(CFWSDiagnosis('COMMENT'))
                            # We can't start a comment in the middle of an
                            # element, so this better be the end
                            end_or_die = True

                        context_stack.append(context)
                        context = Context.COMMENT
                    # Next dot-atom element
                    elif token == Char.DOT:
                        if element_len == 0:
                            # Another dot, already? Fatal error
                            if element_count == 0:
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
# invisible" must comply only with RFC 5322.

                    # Comment
                    if token == Char.OPENPARENTHESIS:
                        if element_len == 0:
                            # Comments at the start of the domain are
                            # deprecated in the text
                            # Comments at the start of a subdomain are
                            # obs-domain
                            # (http://tools.ietf.org/html/rfc5322#section-3.4.1)
                            if element_count == 0:
                                return_status.append(
                                    DeprecatedDiagnosis('CFWS_NEAR_AT'))
                            else:
                                return_status.append(
                                    DeprecatedDiagnosis('COMMENT'))
                        else:
                            return_status.append(CFWSDiagnosis('COMMENT'))
                            # We can't start a comment in the middle of an
                            # element, so this better be the end
                            end_or_die = True

                        context_stack.append(context)
                        context = Context.COMMENT
                    # Next dot-atom element
                    elif token == Char.DOT:
                        if element_len == 0:
                            # Another dot, already? Fatal error
                            if element_count == 0:
                                return_status.append(
                                    InvalidDiagnosis('DOT_START'))
                            else:
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
#   obs-qtext      =  obs-NO-WS-CTL
                        #
                        #   obs-NO-WS-CTL  =  %d1-8 /     ; US-ASCII control
                        #                     %d11 /      ; characters that do
                        #                     %d12 /      ; not include the CR,
                        #                     %d14-31 /   ; LF, and white space
                        #                     %d127       ; characters
                        o = ord(token)

                        if o > 127 or o == 0 or o == 10:
                            # Fatal error
                            return_status.append(
                                InvalidDiagnosis('EXPECTING_QTEXT'))
                        elif o < 32 or o == 127:
                            return_status.append(
                                DeprecatedDiagnosis('QTEXT'))

                        parse_data[Context.LOCALPART] += token
                        atom_list[Context.LOCALPART][element_count] += token
                        element_len += 1
                # -------------------------------------------------------
                # Quoted pair
                # -------------------------------------------------------
                elif context == Context.QUOTEDPAIR:
                    # http://tools.ietf.org/html/rfc5322#section-3.2.1
                    #   quoted-pair     =   ("\" (VCHAR / WSP)) / obs-qp
                    #
                    #   VCHAR           =  %d33-126    ; visible (printing)
                    #                                  ;  characters
                    #
                    #   WSP             =  SP / HTAB   ; white space
                    #
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
skip = True

                            if i+1 == raw_length or (to_char(address[i + 1]) !=
                                                     Char.LF):
                                # Fatal error
                                return_status.append(
                                    InvalidDiagnosis('CR_NO_LF'))
                                break

                        if element_len == 0:
                            if element_count == 0:
                                return_status.append(
                                    DeprecatedDiagnosis('CFWS_NEAR_AT'))
                            else:
                                return_status.append(
                                    DeprecatedDiagnosis('FWS'))
                        else:
                            return_status.append(CFWSDiagnosis('FWS'))
                            # We can't start FWS in the middle of an element,
                            # so this better be the end
                            end_or_die = True

                        context_stack.append(context)
                        context = Context.FWS
                        token_prior = token
                    # atext
                    else:
                        # RFC 5322 allows any atext...
                        # http://tools.ietf.org/html/rfc5322#section-3.2.3
                        #    atext  =  ALPHA / DIGIT / ; Printable US-ASCII
                        #              "!" / "#" /     ; characters not
                        #              "$" / "%" /     ; including specials.