最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How should email addresses that containbe encoded in mailto: URLs? - Stack Overflow

programmeradmin3浏览0评论

Which of the following should be the URL for the email address ~a/[email protected]?

  1. mailto:~a/[email protected]
  2. mailto:~a%[email protected]

Although most clients are able to handle (1), is (2) required by the RFCs?

EID 7919 says this, without commenting on what to do for delimiters in gen-delim.

A number of characters that can appear in MUST be percent-encoded. These are the characters that cannot appear in a URI according to [STD66] as well as "%" (because it is used for percent-encoding) and all the characters in gen-delims except "@" and ":" (i.e., "/", "?", "#", "[", and "]"). Care has to be taken both when encoding as well as when decoding to make sure these operations are applied only once.

RFC 3986 does not require that sub-delimiters used in one component are encoded in other components. Specifically, RFC 3986 Section 2.1 (.1) states that a character requires encoding when it "is being used as a delimiter of, or within, the component."

According to RFC 3986, the mailto URI mailto:Mike&[email protected] is unambiguously the single addr-spec "Mike&[email protected]" because the path component of the mailto scheme does not use "&" as a sub-delimiter.

More comprehensively, the mailto URI mailto:Mike&[email protected]?subject=Use%20of%20%26&body=Should%20be%20fine%20in%20addr-spec must substitute "%26" for "&" in the value of the body header field because "&" is a query component sub-delimiter in the mailto scheme, but the query is the only component where this is required.

However, RFC3986 says that "/" is a gen-delim, while "&" is a sub-delim:

gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"

sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="

[...]

A subset of the reserved characters (gen-delims) is used as delimiters of the generic URI components described in Section 3.

And in section 3.3:

segment = *pchar [...] unreserved / pct-encoded / sub-delims / ":" / "@"

Does this means that the / must be encoded?

发布评论

评论列表(0)

  1. 暂无评论