How to use the pyisemail.diagnosis.CFWSDiagnosis 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
if tag == "ERR":
        d_class = InvalidDiagnosis
    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
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.
                        #              "&" / "'" /     ; Used for atoms.
                        #              "*" / "+" /
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
#   dot-atom-text  =  1*atext *("." 1*atext)
                    #
                    #   quoted-string  =  [CFWS]
                    #                     DQUOTE *([FWS] qcontent) [FWS] DQUOTE
                    #                     [CFWS]
                    #
                    #   obs-local-part =  word *("." word)
                    #
                    #   word           =  atom / quoted-string
                    #
                    #   atom           =  [CFWS] 1*atext [CFWS]
                    if token == Char.OPENPARENTHESIS:
                        if element_len == 0:
                            # Comments are OK at the beginning of an element
                            if element_count == 0:
                                return_status.append(CFWSDiagnosis('COMMENT'))
                            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
                    elif token == Char.DOT:
                        if element_len == 0:
                            # Another dot, already? Fatal error
                            if element_count == 0:
                                return_status.append(
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
# http://tools.ietf.org/html/rfc5322#section-3.2.2
                        #   Runs of FWS, comment, or CFWS that occur between
                        #   lexical tokens in a structured header field are
                        #   semantically interpreted as a single space
                        #   character.

                        # http://tools.ietf.org/html/rfc5322#section-3.2.4
                        #   the CRLF in any FWS/CFWS that appears within the
                        #   quoted string [is] semantically "invisible" and
                        #   therefore not part of the quoted-string
                        parse_data[Context.LOCALPART] += Char.SP
                        atom_list[Context.LOCALPART][element_count] += Char.SP
                        element_len += 1

                        return_status.append(CFWSDiagnosis('FWS'))
                        context_stack.append(context)
                        context = Context.FWS
                        token_prior = token
                    # End of quoted string
                    elif token == Char.DQUOTE:
                        parse_data[Context.LOCALPART] += token
                        atom_list[Context.LOCALPART][element_count] += token
                        element_len += 1
                        context_prior = context
                        context = context_stack.pop()
                    # qtext
                    else:
                        # http://tools.ietf.org/html/rfc5322#section-3.2.4
                        #   qtext          =  %d33 /      ; Printable US-ASCII
                        #                     %d35-91 /   ; characters not
                        #                     %d93-126 /  ; including "\" or
github michaelherold / pyIsEmail / pyisemail / validators / parser_validator.py View on Github external
# 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:
                                return_status.append(
                                    InvalidDiagnosis('CONSECUTIVEDOTS'))