在HTTP1.1标准的rfc2616中,带引号的字符串定义如下。
quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
quoted-pair = "\" CHAR
CHAR = <any US-ASCII character (octets 0 - 127)>
qdtext = <any TEXT except <">>
TEXT = <any OCTET except CTLs, but including LWS>根据这个定义,"“看起来像是一个文本,因此<">\<"> (引号,反斜杠,引号)看起来是一个有效的带引号的字符串。但这与将反斜杠用作转义字符的正确用法相矛盾,甚至可能导致无法明确地确定引用字符串的结尾。我的错误在哪里?
RFC还声明
LWS = [CRLF] 1*( SP | HT )
All linear
white space, including folding, has the same semantics as SP. A
recipient MAY replace any linear white space with a single SP before
interpreting the field value or forwarding the message downstream.我读过这样的解释,即使是带引号的字符串中的LWS也可以被SP取代。如果我从字面上理解RFC,它就是这么说的。我对此感到困惑,因为这意味着引号字符串“","\n ","\n\t \t \t",…都一样。这些被引用的字符串真的不能在语义上区分吗?
发布于 2011-10-25 19:22:16
Re问题1:这是RFC中的一个bug。
参见HTTPbis WG ticket 31和HTTPbis, Part 1, Section 3.2.3。
Re问题2:查看HTTPbis Part 1, 3.2.1 -所以不,你不能区分它们。
https://stackoverflow.com/questions/7886782
复制相似问题