繁体   English   中英

http1.1 rfc2616 中引用字符串的确切语法和语义是什么

[英]what is the exact syntax and semantics of a quoted string in the http1.1 rfc2616

在作为 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>

根据这个定义,“”似乎是一个文本,因此<">\<"> (引号、反斜杠、引号)似乎是一个有效的引用字符串。 但这与反斜杠作为转义字符的正确用法相矛盾,甚至可能导致无法明确地确定引用字符串的结尾。 我的错误在哪里?

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”……都是一样的。 那些带引号的字符串真的不能在语义上区分吗?

关于问题 1:这是 RFC 中的错误。

请参阅HTTPbis WG ticket 31HTTPbis,第 1 部分,第 3.2.3 节

关于问题 2:请参阅HTTPbis 第 1 部分,3.2.1 - 所以不,您无法区分这些。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM