代码之家  ›  专栏  ›  技术社区  ›  KJ Saxena

在URL中,^符号是什么意思?

  •  5
  • KJ Saxena  · 技术社区  · 16 年前

    登录URL的^是什么意思?

    我需要从一个网页上抓取一些链接数据,我使用了一个简单的手写PHP抓取程序。爬虫通常工作得很好;然后我找到了这样一个网址:

    http://www.example.com/example.asp?x7=3^^^^^select%20col1,col2%20from%20table%20where%20recordid%3E=20^^^^^

    此URL在浏览器中键入时工作正常,但我的爬虫程序无法检索此页。我收到一个“HTTP请求失败错误”。

    5 回复  |  直到 8 年前
        1
  •  6
  •   dchest    8 年前

    插入符号(^)不是URL中的保留字符,因此它 应该 可按原样使用。但是,如果您遇到问题,只需将其替换为十六进制编码。 %5E .

    是的,在URL中输入原始SQL就像一个巨大的闪烁霓虹灯标志,上面写着“请利用我!”.

        2
  •  8
  •   Brian R. Bondy    16 年前

    ^ 应对字符进行编码,请参见 RFC 1738 Uniform Resource Locators (URL) :

    其他字符不安全,因为 网关和其他传输代理 已知有时会修改 字符。这些字符是“”, “”,“”,“\”,“^”,“~”,“[”,“]”, 和“”。

    所有不安全字符必须始终 在URL中编码

    您可以尝试URL编码 ^ 性格。

        3
  •  7
  •   Bob Kaufman    16 年前

    基于上下文,我猜他们是一个hospun尝试URL编码引号。

        4
  •  4
  •   Laurence Gonsalves    16 年前

    插入符号既不是保留的,也不是未保留的,这使得它在URL中成为一个“不安全的字符”。它们不应该出现在未编码的URL中。从 RFC2396 :

    2.2. Reserved Characters
    
       Many URI include components consisting of or delimited by, certain
       special characters.  These characters are called "reserved", since
       their usage within the URI component is limited to their reserved
       purpose.  If the data for a URI component would conflict with the
       reserved purpose, then the conflicting data must be escaped before
       forming the URI.
    
          reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                        "$" | ","
    
       The "reserved" syntax class above refers to those characters that are
       allowed within a URI, but which may not be allowed within a
       particular component of the generic URI syntax; they are used as
       delimiters of the components described in Section 3.
    
       Characters in the "reserved" set are not reserved in all contexts.
       The set of characters actually reserved within any given URI
       component is defined by that component. In general, a character is
       reserved if the semantics of the URI changes if the character is
       replaced with its escaped US-ASCII encoding.
    
    2.3. Unreserved Characters
    
       Data characters that are allowed in a URI but do not have a reserved
       purpose are called unreserved.  These include upper and lower case
       letters, decimal digits, and a limited set of punctuation marks and
       symbols.
    
          unreserved  = alphanum | mark
    
          mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
    
       Unreserved characters can be escaped without changing the semantics
       of the URI, but this should not be done unless the URI is being used
       in a context that does not allow the unescaped character to appear.
    
    2.4. Escape Sequences
    
       Data must be escaped if it does not have a representation using an
       unreserved character; this includes data that does not correspond to
       a printable character of the US-ASCII coded character set, or that
       corresponds to any US-ASCII character that is disallowed, as
       explained below.
    
        5
  •  0
  •   Gav    16 年前

    爬虫程序可能正在使用正则表达式来解析URL,因此会发生故障,因为插入符号(^)表示行首。我认为这些URL是非常糟糕的做法,因为它们公开了底层数据库结构;写这篇文章的人可能会考虑进行严重的重构!

    嗯!

    推荐文章