What characters are allowed in an email address?

后端 未结 17 2121
天命终不由人
天命终不由人 2020-11-22 00:29

I\'m not asking about full email validation.

I just want to know what are allowed characters in user-name and server parts of email address

17条回答
  •  被撕碎了的回忆
    2020-11-22 01:10

    The answer is (almost) ALL (7-bit ASCII).
    If the inclusion rules is "...allowed under some/any/none conditions..."

    Just by looking at one of several possible inclusion rules for allowed text in the "domain text" part in RFC 5322 at the top of page 17 we find:

    dtext          =   %d33-90 /          ; Printable US-ASCII
                       %d94-126 /         ;  characters not including
                       obs-dtext          ;  "[", "]", or "\"
    

    the only three missing chars in this description are used in domain-literal [], to form a quoted-pair \, and the white space character (%d32). With that the whole range 32-126 (decimal) is used. A similar requirement appear as "qtext" and "ctext". Many control characters are also allowed/used. One list of such control chars appears in page 31 section 4.1 of RFC 5322 as obs-NO-WS-CTL.

    obs-NO-WS-CTL  =   %d1-8 /            ; US-ASCII control
                       %d11 /             ;  characters that do not
                       %d12 /             ;  include the carriage
                       %d14-31 /          ;  return, line feed, and
                       %d127              ;  white space characters
    

    All this control characters are allowed as stated at the start of section 3.5:

    .... MAY be used, the use of US-ASCII control characters (values
         1 through 8, 11, 12, and 14 through 31) is discouraged ....
    

    And such an inclusion rule is therefore "just too wide". Or, in other sense, the expected rule is "too simplistic".

提交回复
热议问题