在作为HTTP/1.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>
Run Code Online (Sandbox Code Playgroud)
有了这个定义, "" 似乎是一个 TEXT,因此<">\<">(quote, backslash, quote) 似乎是一个有效的带引号的字符串。但这与反斜杠作为转义字符的正确使用相矛盾,甚至可能导致不能明确地确定引用字符串的结尾。我的错误在哪里?
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.
Run Code Online (Sandbox Code Playgroud)
我已经阅读了解释,即使是带引号的字符串中的 LWS 也可以被 SP 替换。如果我从字面上理解 RFC,那就是它所说的。我对此感到困惑,因为这意味着引号中的字符串 " "、"\n "、"\n\t \t \t", ... 都是一样的。那些带引号的字符串真的不能在语义上区分吗?
问题 1:这是 RFC 中的一个错误。
请参阅HTTPbis WG 票证 31和HTTPbis,第 1 部分,第 3.2.3 节。
问题 2:请参阅HTTPbis 第 1 部分,3.2.1 - 所以不,您无法区分这些。
| 归档时间: |
|
| 查看次数: |
3589 次 |
| 最近记录: |