【问题标题】:How do browsers handle "@" within the url domain?浏览器如何处理 url 域中的“@”?
【发布时间】:2020-10-17 17:04:33
【问题描述】:

如果您访问此网址https://stackoverflow.com@duckduckgo.com/,它会将您带到duckduckgo。如果你尝试curl,它仍然会返回duckduckgo html。

我找不到有关此行为的任何解释或 RFC。幕后发生了什么?为什么stackoverflow.com 部分被完全忽略?

【问题讨论】:

    标签: redirect http-redirect


    【解决方案1】:

    在 URL 解析中,@ 通常用于分隔 userhost 信息。

    我认为直到@ 一切都被解析为user info,然后用于定义host 其余部分。

    见:

    另外,RFC-1738 包含以下关于保留字符:

       Many URL schemes reserve certain characters for a special meaning:
       their appearance in the scheme-specific part of the URL has a
       designated semantics. If the character corresponding to an octet is
       reserved in a scheme, the octet must be encoded.  The characters ";",
       "/", "?", ":", "@", "=" and "&" are the characters which may be
       reserved for special meaning within a scheme. No other characters may
       be reserved within a scheme.
    

    最后来自RFC-3986

    authority   = [ userinfo "@" ] host [ ":" port ]
    

    请务必阅读 3.2. Authority section3.2.1. User Information 部分。

    【讨论】:

      猜你喜欢
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多