| 1 |
wakaba |
1.1 |
#?SuikaWiki/0.9 default-name="不正なFrom:欄です" |
| 2 |
|
|
|
| 3 |
|
|
|
| 4 |
|
|
* quoted-string の仕様 |
| 5 |
|
|
|
| 6 |
|
|
|
| 7 |
|
|
** RFC 724 (電子メイル) |
| 8 |
|
|
|
| 9 |
|
|
[26] [CODE[quoted-string]] を規定した最初のメイル規格です。 |
| 10 |
|
|
基本的には現在の電子メイル仕様と同じなのですが、 |
| 11 |
|
|
[CODE[quoted-pair]] が無い代わりに [CODE(ABNF)[<"">]] で |
| 12 |
|
|
[CODE(ABNF)[<">]] を表現しました。 |
| 13 |
|
|
|
| 14 |
|
|
この規格は廃止されて既に随分経っていて、この形式のメッセージはみたことがありません。 |
| 15 |
|
|
(但し RFC 724 の [CODE[quoted-string]] の形式と |
| 16 |
|
|
[[Micro$oft]] の [[VisualBasic]] の[[文字列型]]の表記法は同じです。 |
| 17 |
|
|
おそらく偶然だとは思いますが。) |
| 18 |
|
|
|
| 19 |
|
|
[16] |
| 20 |
|
|
[PRE[ |
| 21 |
|
|
<quoted-string> ::= <double quote mark ("), decimal 34> |
| 22 |
|
|
<a sequence of one or more TELNET |
| 23 |
|
|
ASCII characters, where two |
| 24 |
|
|
adjacent quotes are treated as a |
| 25 |
|
|
single quote and part of the |
| 26 |
|
|
string> <"> |
| 27 |
|
|
]PRE] |
| 28 |
|
|
|
| 29 |
|
|
>>16 を [[ABNF]] で書き直すと、こうです。 |
| 30 |
|
|
- [19] quoted-string = <"> qcontent <"> |
| 31 |
|
|
- [20] qcontent = qtext / quotes |
| 32 |
|
|
- [21] qtext = 1*(%x00-09 / %x0B-0C / %x0E-21 / %x23-7F) |
| 33 |
|
|
- [22] quotes = <""> |
| 34 |
|
|
|
| 35 |
|
|
[23] >>16 では <"> の出現が禁じられていませんが、常識的に考えてそんなもんは出てきてはいかんでしょう。 (>>21) |
| 36 |
|
|
|
| 37 |
|
|
[25] >>16 では ASCII なんでもありのように読めるけど、 >>24 |
| 38 |
|
|
を読むと [CODE[CRLF]] が認められていないことがわかる。 (>>21) |
| 39 |
|
|
(単独の [CODE[LF]] は認められているんだろうか?) |
| 40 |
|
|
|
| 41 |
|
|
[24] '''[INS[II.B.1.C.]]3) Quoted strings''' |
| 42 |
|
|
|
| 43 |
|
|
> Where permitted (i.e., in structured fields) quoted |
| 44 |
|
|
strings are treated as a single symbol (i.e. equivalent |
| 45 |
|
|
to an <atom> syntactically). However, if quoted strings |
| 46 |
|
|
are to be "folded" onto multiple lines, then the syntax |
| 47 |
|
|
for folding must be adhered to (See items II.B.1.a.1, |
| 48 |
|
|
above, and II.B.1.c.6, below.) Note that the official |
| 49 |
|
|
semantics do not encounter <crlf>s in quoted strings, |
| 50 |
|
|
although particular parsing programs may wish to note |
| 51 |
|
|
their presence. |
| 52 |
|
|
> [INS[認められているところ (つまり構造化欄の中) では引用符で囲まれた文字列を単一の記号 (つまり構文的に <atom> と等しいもの) として取り扱います。しかし、引用符で囲まれた文字列が複数行に「折畳まれ」ている時は、折畳みの構文に従わなければいけません。なお、公式な意味では引用符で囲まれた文字列中に <crlf> は現れません。解析プログラムでこの出現に注意したいと思うのがあるかもしれませんが。]] |
| 53 |
|
|
|
| 54 |
|
|
- [18] BS が最初に来てはいけません。 (>>12 と同じ) |
| 55 |
|
|
[[#comment]] |
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
** RFC 733 (電子メイル) |
| 59 |
|
|
|
| 60 |
|
|
[13] RFC 733 の規定はほぼそのまま RFC 822 |
| 61 |
|
|
に受け継がれました。詳しくは RFC 822 の節 (>>14) と RFC 733 |
| 62 |
|
|
<urn:ietf:rfc:733> をご覧下さい。 |
| 63 |
|
|
|
| 64 |
|
|
[PRE[ |
| 65 |
|
|
quoted-string = <"> *(qtext/quoted-pair) <">; Any number of qtext |
| 66 |
|
|
; chars or any |
| 67 |
|
|
; quoted char. |
| 68 |
|
|
qtext = <any CHAR excepting <"> ; => may be folded |
| 69 |
|
|
and CR, and including |
| 70 |
|
|
linear-white-space> |
| 71 |
|
|
quoted-pair = "\" CHAR |
| 72 |
|
|
]PRE] |
| 73 |
|
|
|
| 74 |
|
|
[15] [CODE(ABNF)[qtext]] で [CODE(ABNF)["\"]] |
| 75 |
|
|
が除外されていないので、これでは [CODE(ABNF)[quoted-pair]] |
| 76 |
|
|
の構文解析が出来なくなってしまいますが、 RFC 822 |
| 77 |
|
|
で修正されています (>>14) し、単なる不具合と考えて良いでしょう。 |
| 78 |
|
|
|
| 79 |
|
|
[17] RFC 724 の方法 (>>16) とは互換性がありません。 |
| 80 |
|
|
|
| 81 |
|
|
[[#comment]] |
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
** RFC 822 (電子メイル) |
| 85 |
|
|
|
| 86 |
|
|
[14] |
| 87 |
|
|
[PRE[ |
| 88 |
|
|
quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or |
| 89 |
|
|
; quoted chars. |
| 90 |
|
|
[INS[; 普通の qtext か引用符で囲んだ文字]] |
| 91 |
|
|
qtext = <any CHAR excepting <">, ; => may be folded |
| 92 |
|
|
"\" & CR, and including |
| 93 |
|
|
linear-white-space> |
| 94 |
|
|
[INS[<任意の CHAR。但し <">, "\", CR を除き、]] |
| 95 |
|
|
[INS[linear-white-space を含む>]] |
| 96 |
|
|
[INS[; ⇒折畳んでも良い。]] |
| 97 |
|
|
CHAR = <any ASCII character> ; ( 0-177, 0.-127.) |
| 98 |
|
|
quoted-pair = "\" CHAR ; may quote any char |
| 99 |
|
|
[INS[; 任意の文字を quote 可能]] |
| 100 |
|
|
]PRE] |
| 101 |
|
|
|
| 102 |
|
|
- [1] [CODE(ABNF)[quoted-string]] 中に [[comment]] はつかえません。 (3.4.3) |
| 103 |
|
|
- [2] 両側の <"> と [CODE(ABNF)[quoted-char]] の "\" は [CODE(ABNF)[quoted-string]] のデータの一部ではありません。 (3.4.4) |
| 104 |
|
|
- [12] [[制御文字]] [[BS]] が [CODE(ABNF)[quoted-string]] の初めに来てはいけません。 |
| 105 |
|
|
|
| 106 |
|
|
[3] [CODE(ABNF)[phrase]] 中では、前後に隣接する [CODE(ABNF)[word]] |
| 107 |
|
|
との間に [CODE(ABNF)[SPACE]] が1つあると仮定します。 |
| 108 |
|
|
(実際の [CODE(ABNF)[LWSP-char]] の数によらず [CODE(ABNF)[1SPACE]] |
| 109 |
|
|
とします。) |
| 110 |
|
|
|
| 111 |
|
|
複数の [CODE(ABNF)[LWSP-char]] を入れたいときは <"> |
| 112 |
|
|
の内側に入れます。 (3.4.4) |
| 113 |
|
|
|
| 114 |
|
|
例えば、 [SAMP[atom1 (SP) "quoted-string" (SP) (TAB) atom2]] |
| 115 |
|
|
は ''atom1 (SP) quoted-string (SP) atom2'' と解釈され、 |
| 116 |
|
|
[SAMP[atom1 (SP) " (TAB) quoted-string" (TAB) (TAB) atom2]] |
| 117 |
|
|
は ''atom1 (SP) (TAB) quoted-string (SP) atom2'' と解釈されます。 |
| 118 |
|
|
|
| 119 |
|
|
[4] |
| 120 |
|
|
|
| 121 |
|
|
> '''3.4.5. QUOTED-STRINGS [INS[引用符で囲まれた文字列]]''' |
| 122 |
|
|
> Where permitted (i.e., in words in structured fields) |
| 123 |
|
|
quoted-strings are treated as a single symbol. That is, a |
| 124 |
|
|
quoted-string is equivalent to an atom, syntactically. If a |
| 125 |
|
|
quoted-string is to be "folded" onto multiple lines, then the syntax |
| 126 |
|
|
for folding must be adhered to. (See the "Lexical Analysis of |
| 127 |
|
|
Messages" section on "Folding Long Header Fields" above, and |
| 128 |
|
|
the section on "Case Independence" below.) Therefore, the |
| 129 |
|
|
official semantics do not "see" any bare CRLFs that are in |
| 130 |
|
|
quoted-strings; however particular parsing programs may wish |
| 131 |
|
|
to note their presence. For such programs, it would be |
| 132 |
|
|
reasonable to interpret a "CRLF LWSP-char" as being a CRLF which |
| 133 |
|
|
is part of the quoted-string; i.e., the CRLF is kept and the |
| 134 |
|
|
LWSP-char is discarded. Quoted CRLFs (i.e., a backslash |
| 135 |
|
|
followed by a CR followed by a LF) are also subject to rules of |
| 136 |
|
|
folding, but the presence of the quoting character (backslash) |
| 137 |
|
|
explicitly indicates that the CRLF is data to the quoted |
| 138 |
|
|
string. Stripping off the first following LWSP-char is also |
| 139 |
|
|
appropriate when parsing quoted CRLFs. |
| 140 |
|
|
|
| 141 |
|
|
認められているところ (例えば構造化欄の [CODE(ABNF)[word]] 中) |
| 142 |
|
|
では [CODE(ABNF)[quoted-string]] は単一の記号として扱われます。 |
| 143 |
|
|
つまり、構文的には 1つの [CODE(ABNF)[quoted-string]] は |
| 144 |
|
|
1つの [CODE(ABNF)[atom]] に相当します。 [CODE(ABNF)[quoted-string]] |
| 145 |
|
|
が複数行に「折畳まれ」る場合、折畳みの構文を守らないといけません。 |
| 146 |
|
|
(上の「メッセージの字句解析」節の「[[長い頭欄の折畳み]]」と下の |
| 147 |
|
|
「大文字・小文字不区別性」を参照。) 従って、公式な意味では生の |
| 148 |
|
|
[CODE(ABNF)[CRLF]] を [CODE(ABNF)[quoted-string]] |
| 149 |
|
|
中で見ることはありません。 |
| 150 |
|
|
しかし解析プログラムにはこの出現に注意したいと願うのもあるかもしれません。 |
| 151 |
|
|
そうしたプログラムでは、「[CODE(ABNF)[CRLF]] [CODE(ABNF)[LWSP-char]]」 |
| 152 |
|
|
を [CODE(ABNF)[quoted-string]] の一部である [CODE(ABNF)[CRLF]] |
| 153 |
|
|
と解釈するのが良いでしょう。従って [CODE(ABNF)[CRLF]] |
| 154 |
|
|
は残して [CODE(ABNF)[LWSP-char]] は捨てます。 Quote |
| 155 |
|
|
された [CODE(ABNF)[CRLF]] (つまり逆斜線に CR と LF |
| 156 |
|
|
が続くもの。) も折畳みの規則の対象ですが、 quote 文字 |
| 157 |
|
|
(逆斜線) の存在が [CODE(ABNF)[CRLF]] が [CODE(ABNF)[quoted-string]] |
| 158 |
|
|
のデータの一部であることを明示しています。 Quote |
| 159 |
|
|
された [CODE(ABNF)[CRLF]] を解析する時には最初に続く |
| 160 |
|
|
[CODE(ABNF)[LWSP-char]] を読み飛ばすのも適切でしょう。 |
| 161 |
|
|
|
| 162 |
|
|
- [5] >>4 の後半部分の解釈: |
| 163 |
|
|
- [6] (a) 「qtext CRLF LWSP-char qtext」は「qtext LWSP-char qtext」と解釈する。 |
| 164 |
|
|
- [7] (b) 「qtext CRLF LWSP-char qtext」は「qtext CRLF qtext」と解釈しても良い。 |
| 165 |
|
|
- [8] (A) 「qtext "\" CRLF LWSP-char qtext」は「qtext CRLF LWSP-char qtext」と解釈する。 |
| 166 |
|
|
- [9] (B) 「qtext "\" CRLF LWSP-char qtext」は「qtext CRLF qtext」と解釈しても良い。 |
| 167 |
|
|
- [10] >>6-9 であってますかね? しかしこうだとすると、(欄の定義を見ずに) CRLF LWSP-char ⇒ LWSP-char という風に unfolding を実装することが出来なくなってしまいます... |
| 168 |
|
|
|
| 169 |
|
|
[[#comment]] |
| 170 |
|
|
|
| 171 |
|
|
|
| 172 |
|
|
** HTTP メッセージ |
| 173 |
|
|
|
| 174 |
|
|
RFC 1945 [[HTTP/1.0]] によると、 |
| 175 |
|
|
|
| 176 |
|
|
= quoted-string = ( <"> *(qdtext) <"> ) |
| 177 |
|
|
= qdtext = <any CHAR except <"> and CTLs, but including LWS> |
| 178 |
|
|
|
| 179 |
|
|
[55] RFC 2068 (HTTP/1.1) によると: |
| 180 |
|
|
- [56] quoted-string = ( <"> *(qdtext) <"> ) |
| 181 |
|
|
- [57] qdtext = <any TEXT except <">> |
| 182 |
|
|
- [58] quoted-pair = "\" CHAR |
| 183 |
|
|
|
| 184 |
|
|
[59] RFC 2616 [[HTTP/1.1]] によると、 |
| 185 |
|
|
|
| 186 |
|
|
= quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) |
| 187 |
|
|
= qdtext = <any TEXT except <">> |
| 188 |
|
|
= quoted-pair = "\" CHAR |
| 189 |
|
|
|
| 190 |
|
|
[60] HTTP/1.0 では quoted-pair が使えなかったと。それで HTTP/1.1 |
| 191 |
|
|
でも使えるけど使えないみたいな玉虫色。 See [[メッセージ頭のcomment]] の HTTP |
| 192 |
|
|
のとこ。 |
| 193 |
|
|
(さすがに RFC 733 の bug (>>15) を引きずってるのでは''ない''でしょう。) |
| 194 |
|
|
|
| 195 |
|
|
= http1.0.quoted-string = <"> http1.0.qcontent <"> |
| 196 |
|
|
= http1.0.qcontent = *http1.0.qtext |
| 197 |
|
|
= http1.0.qtext = %x20-21 / %x23-%x7E / FWS |
| 198 |
|
|
|
| 199 |
|
|
= http1.1.quoted-string = <"> http1.1.qcontent <"> |
| 200 |
|
|
= http1.1.qcontent = *( http1.1.qtext / http.quoted-pair ) |
| 201 |
|
|
= http1.1.qtext = %x00-21 / %x23-5B / %x5D-FF |
| 202 |
|
|
= http.quoted-string = "\" %x00-7F |
| 203 |
|
|
|
| 204 |
|
|
[46] たぶん HTTP/1.1 でも qdtext に LWS が使えると解釈したほーがいいんだろうけど、 |
| 205 |
|
|
HTTP だと単独の CR が使えるから BNF がちょいとばかり複雑になるなあ。 |
| 206 |
|
|
|
| 207 |
|
|
[54] HTTP でも [CODE(ABNF)[CHAR = %x00-7F]] ですから、 [CODE(ABNF)[quoted-pair]] |
| 208 |
|
|
で8ビットの値を使用することは出来ません。 |
| 209 |
|
|
- [81] なお、8ビットの値は、 [[HTTP/1.0]] (RFC 1945) では「[[ISO-8859-1]] と解釈しても良」く、 HTTP/1.1 (RFC 2068/2616) では [CODE(CHARSET)[ISO-8859-1]] です。 |
| 210 |
|
|
- [82] [[RFC2831]] ([[SASL]]) にも [CODE(ABNF)[quoted-string]] の定義がありますが、 RFC 2616 からの引用で同じものです。 |
| 211 |
|
|
[[#comment]] |
| 212 |
|
|
|
| 213 |
|
|
|
| 214 |
|
|
** RTSP メッセージ |
| 215 |
|
|
|
| 216 |
|
|
[48] [[HTTP/1.1]] ([[RFC2068]]) 派生プロトコルの1つ、 [[RTSP/1.0]] ([[RFC2326]]) |
| 217 |
|
|
は次のように定義しています。 |
| 218 |
|
|
- [49] quoted-string = ( <"> *(qdtext) <"> ) |
| 219 |
|
|
- [50] qdtext = <any TEXT except <">> [INS[;; %x20-21 / %x23-7E / %x80-FF]] |
| 220 |
|
|
- [51] quoted-pair = "\" CHAR [INS[;; "\" %x00-7F]] |
| 221 |
|
|
|
| 222 |
|
|
[52] RTSP において8ビットの値は [[UTF-8]] と解釈されます。 |
| 223 |
|
|
>>51 にあるように8ビットの時は [CODE(ABNF)[quoted-pair]] |
| 224 |
|
|
が使えません。単に HTTP からのコピペで済ませたから使えないままなのか、 UTF-8 |
| 225 |
|
|
の2オクテット目以降を quote するのかの問題が生じるのが嫌だから敢えて使えないままにしたのかはわかりません。 |
| 226 |
|
|
|
| 227 |
|
|
[53] >>49-50 [CODE(ABNF)[quoted-pair]] をどこに使うのかわからないのは HTTP |
| 228 |
|
|
譲りでしょうか(藁)。 |
| 229 |
|
|
[[#comment]] |
| 230 |
|
|
|
| 231 |
|
|
|
| 232 |
|
|
** SIP メッセージ |
| 233 |
|
|
|
| 234 |
|
|
[27] HTTP を元にしてる SIP だけど、びみょーに違う。いやらしーのは |
| 235 |
|
|
HTTP/1.1 と同じ。(たぶん何も考えずに写したんだ。) |
| 236 |
|
|
|
| 237 |
|
|
= quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) |
| 238 |
|
|
= qdtext = <any TEXT-UTF8 except <">> |
| 239 |
|
|
= quoted-pair = " \ " CHAR |
| 240 |
|
|
|
| 241 |
|
|
[47] [CODE(ABNF)[" \ "]] はたぶん [CODE(ABNF)["\"]] の間違いだ。そー信じたい。 |
| 242 |
|
|
|
| 243 |
|
|
= sip.quoted-string = <"> sip.quoted-string <"> |
| 244 |
|
|
= sip.qcontent = *( sip.qtext / http.quoted-pair ) |
| 245 |
|
|
= sip.qtext = %x20-21 / %x23-5B / %x5D-7E / utf8-xtra-char / FWS |
| 246 |
|
|
[[#comment]] |
| 247 |
|
|
|
| 248 |
|
|
|
| 249 |
|
|
** RFC 2822 (電子メイル) |
| 250 |
|
|
|
| 251 |
|
|
|
| 252 |
|
|
*** 3.2.2. Quoted characters |
| 253 |
|
|
|
| 254 |
|
|
> Some characters are reserved for special interpretation, such as |
| 255 |
|
|
delimiting lexical tokens. To permit use of these characters as |
| 256 |
|
|
uninterpreted data, a quoting mechanism is provided. |
| 257 |
|
|
|
| 258 |
|
|
[35] 幾つかの文字は単語字句を区切るためなどの特別な解釈に予約されています。 |
| 259 |
|
|
こうした文字を解釈しないデータとして使うことを可能にするため、 |
| 260 |
|
|
quote 機構を提供します。 |
| 261 |
|
|
|
| 262 |
|
|
- [36] quoted-pair = ("\" text) / obs-qp |
| 263 |
|
|
|
| 264 |
|
|
> Where any quoted-pair appears, it is to be interpreted as the text |
| 265 |
|
|
character alone. That is to say, the "\" character that appears as |
| 266 |
|
|
part of a quoted-pair is semantically "invisible". |
| 267 |
|
|
|
| 268 |
|
|
[37] [CODE(ABNF)[quoted-pair]] が出現したら、これは [CODE(ABNF)[text]] |
| 269 |
|
|
文字だけであると解釈されます。言い換えれば、 [CODE(ABNF)[quoted-pair]] |
| 270 |
|
|
の一部として出現する [CODE(ABNF)["\"]] 文字は意味的には「不可視」です。 |
| 271 |
|
|
|
| 272 |
|
|
> Note: The "\" character may appear in a message where it is not part |
| 273 |
|
|
of a quoted-pair. A "\" character that does not appear in a |
| 274 |
|
|
quoted-pair is not semantically invisible. The only places in this |
| 275 |
|
|
standard where quoted-pair currently appears are ccontent, qcontent, |
| 276 |
|
|
dcontent, no-fold-quote, and no-fold-literal. |
| 277 |
|
|
|
| 278 |
|
|
[38] 注意: [CODE(ABNF)["\"]] 文字はメッセージ中で [CODE(ABNF)[quoted-pair]] |
| 279 |
|
|
の一部でない場所で出現するかもしれません。 [CODE(ABNF)[quoted-pair]] |
| 280 |
|
|
中でない [CODE(ABNF)["\"]] は意味的に不可視ではありません。 |
| 281 |
|
|
この規格中で現在 [CODE(ABNF)[quoted-pair]] が出現するのは |
| 282 |
|
|
[CODE(ABNF)[ccontent]], [CODE(ABNF)[qcontent]], [CODE(ABNF)[dcontent]], |
| 283 |
|
|
[CODE(ABNF)[no-fold-quote]], [CODE(ABNF)[no-fold-literal]] だけです。 |
| 284 |
|
|
|
| 285 |
|
|
|
| 286 |
|
|
*** 3.2.5. Quoted strings |
| 287 |
|
|
|
| 288 |
|
|
> Strings of characters that include characters other than those |
| 289 |
|
|
allowed in atoms may be represented in a quoted string format, where |
| 290 |
|
|
the characters are surrounded by quote (DQUOTE, ASCII value 34) characters. |
| 291 |
|
|
|
| 292 |
|
|
[28] [[atom]] 中で認められている以外の文字を含む文字列は引用符で囲まれた文字列形式, |
| 293 |
|
|
すなわち引用符 ([CODE(ABNF)[DQUOTE]], [[ASCII]] 値 [CODE[34]]) |
| 294 |
|
|
文字で囲まれた文字を使って表現しても構いません。 |
| 295 |
|
|
|
| 296 |
|
|
[29] |
| 297 |
|
|
[PRE[ |
| 298 |
|
|
qtext = NO-WS-CTL / ; Non white space controls |
| 299 |
|
|
[INS[; 非空白間隔制御文字]] |
| 300 |
|
|
%d33 / ; The rest of the US-ASCII |
| 301 |
|
|
%d35-91 / ; characters not including "\" |
| 302 |
|
|
%d93-126 ; or the quote character |
| 303 |
|
|
[INS[; "\" や引用符文字を除いた US-ASCII 文字]] |
| 304 |
|
|
]PRE] |
| 305 |
|
|
|
| 306 |
|
|
- [30] qcontent = qtext / quoted-pair |
| 307 |
|
|
- [31] quoted-string = [CFWS] DQUOTE *([FWS] qcontent) [FWS] DQUOTE [CFWS] |
| 308 |
|
|
|
| 309 |
|
|
> A quoted-string is treated as a unit. That is, quoted-string is |
| 310 |
|
|
identical to atom, semantically. Since a quoted-string is allowed to |
| 311 |
|
|
contain FWS, folding is permitted. Also note that since quoted-pair |
| 312 |
|
|
is allowed in a quoted-string, the quote and backslash characters may |
| 313 |
|
|
appear in a quoted-string so long as they appear as a quoted-pair. |
| 314 |
|
|
|
| 315 |
|
|
[32] [CODE(ABNF)[quoted-string]] は1単位として扱います。 |
| 316 |
|
|
つまり、 [CODE(ABNF)[quoted-string]] は意味的には [CODE(ABNF)[atom]] |
| 317 |
|
|
と同一です。 [CODE(ABNF)[quoted-string]] は [CODE(ABNF)[FWS]] |
| 318 |
|
|
を含むことを認めていますから、[[折り畳み]]が認められます。 |
| 319 |
|
|
[CODE(ABNF)[quoted-string]] 中で [CODE(ABNF)[quoted-pair]] |
| 320 |
|
|
が認められているので、引用符文字及び逆斜線文字は |
| 321 |
|
|
[CODE(ABNF)[quoted-pair]] としてなら [CODE(ABNF)[quoted-string]] |
| 322 |
|
|
中に出現しても構わないことにも注意して下さい。 |
| 323 |
|
|
|
| 324 |
|
|
> Semantically, neither the optional CFWS outside of the quote |
| 325 |
|
|
characters nor the quote characters themselves are part of the |
| 326 |
|
|
quoted-string; the quoted-string is what is contained between the two |
| 327 |
|
|
quote characters. As stated earlier, the "\" in any quoted-pair and |
| 328 |
|
|
the CRLF in any FWS/CFWS that appears within the quoted-string are |
| 329 |
|
|
semantically "invisible" and therefore not part of the quoted-string either. |
| 330 |
|
|
|
| 331 |
|
|
[33] 意味的には、引用符文字の外側の省略可能な [CODE(ABNF)[CFWS]] |
| 332 |
|
|
も引用符文字自体も [CODE(ABNF)[quoted-string]] の一部ではありません。 |
| 333 |
|
|
[CODE(ABNF)[quoted-string]] は2つの引用符文字の間に含まれるものです。 |
| 334 |
|
|
上述の通り、 [CODE(ABNF)[quoted-string]] 中に出現する |
| 335 |
|
|
[CODE(ABNF)[quoted-pair]] 中の [CODE(ABNF)["\"]] 及び |
| 336 |
|
|
[CODE(ABNF)[FWS]]/[CODE(ABNF)[CFWS]] 中の [CODE(ABNF)[CRLF]] |
| 337 |
|
|
は意味的には「不可視」であって従ってこれもまた [CODE(ABNF)[quoted-string]] |
| 338 |
|
|
の一部ではありません。 |
| 339 |
|
|
|
| 340 |
|
|
|
| 341 |
|
|
*** メモ |
| 342 |
|
|
|
| 343 |
|
|
[42] |
| 344 |
|
|
[PRE[ |
| 345 |
|
|
text = %d1-9 / ; Characters excluding CR and LF |
| 346 |
|
|
%d11 / [INS[; CR, LF を除く文字]] |
| 347 |
|
|
%d12 / [INS[;; RFC 2822 3.2.1]] |
| 348 |
|
|
%d14-127 / |
| 349 |
|
|
obs-text |
| 350 |
|
|
[45] |
| 351 |
|
|
obs-char = %d0-9 / %d11 / ; %d0-127 except CR and |
| 352 |
|
|
%d12 / %d14-127 ; LF |
| 353 |
|
|
-[43] obs-text = *LF *CR *(obs-char *LF *CR) ;; RFC 2822 4.1 |
| 354 |
|
|
-[44] obs-qp = "\" (%d0-127) ;; RFC 2822 4.1 |
| 355 |
|
|
-[40] no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE ;; RFC 2822 3.6.4 (Message-ID) |
| 356 |
|
|
]PRE] |
| 357 |
|
|
|
| 358 |
|
|
- [39] >>38 にあるように、 [CODE(ABNF)[quoted-pair]] |
| 359 |
|
|
が使える場所は [CODE(ABNF)[quoted-string]], [[comment]], [[domain-literal]] です。 |
| 360 |
|
|
- [41] >>40 は新構文の [[Message-ID]] で使います。 Message-ID |
| 361 |
|
|
中での折り畳みは非推奨ということで、その他は [CODE(ABNF)[quoted-string]] |
| 362 |
|
|
と同じです。 |
| 363 |
|
|
[[#comment]] |
| 364 |
|
|
|
| 365 |
|
|
|
| 366 |
|
|
** USEFOR (電子ニュース) |
| 367 |
|
|
|
| 368 |
|
|
[61] [[usefor-article]] (08) は次のような構文を定義しています。 |
| 369 |
|
|
- [64] quoted-string = [CFWS] DQUOTE *( [FWS] qcontent ) [FWS] DQUOTE [CFWS] |
| 370 |
|
|
- [62] quoted-pair = "\" text |
| 371 |
|
|
- [63] qcontent = qtext / quoted-pair |
| 372 |
|
|
[65] |
| 373 |
|
|
[PRE[ |
| 374 |
|
|
text = %d1-9 / ; all UTF-8 characters except |
| 375 |
|
|
%d11-12 / ; US-ASCII NUL, CR and LF |
| 376 |
|
|
%d14-127 / |
| 377 |
|
|
UTF8-xtra-char |
| 378 |
|
|
]PRE] |
| 379 |
|
|
|
| 380 |
|
|
- [67] strict-quoted-string = [CFWS] DQUOTE *( [FWS] strict-qcontent ) [FWS] DQUOTE [CFWS] |
| 381 |
|
|
- [68] strict-quoted-pair = "\" strict-text |
| 382 |
|
|
- [69] strict-qcontent = strict-qtext / strict-quoted-pair |
| 383 |
|
|
|
| 384 |
|
|
[66] |
| 385 |
|
|
[PRE[ |
| 386 |
|
|
strict-qtext = NO-WS-CTL / ; qtext restricted to |
| 387 |
|
|
%d33 / ; US-ASCII |
| 388 |
|
|
%d35-91 / |
| 389 |
|
|
%d93-126 |
| 390 |
|
|
[71] |
| 391 |
|
|
no-fold-quote = DQUOTE |
| 392 |
|
|
*( strict-qtext / "\\" / "\" DQUOTE ) |
| 393 |
|
|
qspecial |
| 394 |
|
|
*( strict-qtext / "\\" / "\" DQUOTE ) |
| 395 |
|
|
DQUOTE |
| 396 |
|
|
[72] |
| 397 |
|
|
qspecial = "(" / ")" / ; same as specials except |
| 398 |
|
|
"<" / ">" / ; "\" and DQUOTE quoted |
| 399 |
|
|
"[" / "]" / |
| 400 |
|
|
":" / ";" / |
| 401 |
|
|
"@" / "\\" / |
| 402 |
|
|
"," / "." / |
| 403 |
|
|
"\" DQUOTE |
| 404 |
|
|
]PRE] |
| 405 |
|
|
|
| 406 |
|
|
[70] RFC 2822 の定義 (>>31) から非推奨構文を除き [[UTF-8]] の文字を加えたものが |
| 407 |
|
|
[CODE(ABNF)[quoted-string]] (>>64) 及び [CODE(ABNF)[quoted-pair]] (>>62) |
| 408 |
|
|
です。また、電子メイル・アドレスの [[local-part]] などで使われる |
| 409 |
|
|
[CODE(ABNF)[strict-quoted-string]] (>>67) は、 RFC 2822 の [CODE(ABNF)[quoted-string]] |
| 410 |
|
|
(>>31) から非推奨構文を除いたものです。 |
| 411 |
|
|
|
| 412 |
|
|
[73] [[Message-ID]] で使う RFC 2822 の [CODE(ABNF)[no-fold-quote]] (>>40) |
| 413 |
|
|
も更に厳格化されています。これはニュースに於いてメイル以上に重要な意味を持つ |
| 414 |
|
|
Message-ID の比較などを簡単に行えるようにするためです。 |
| 415 |
|
|
Usefor の [CODE(ABNF)[no-fold-quote]] は、 RFC 2822 同様に UTF-8 |
| 416 |
|
|
の文字が使えない上に、 [CODE(ABNF)[quoted-pair]] が使えるのは |
| 417 |
|
|
[CODE(ABNF)["\\"]] 及び [CODE(ABNF)[<\">]] の2種類のみです。 |
| 418 |
|
|
又、 [CODE(ABNF)[specials]] に該当する文字が含まれていない場合は使うことが出来ません。 |
| 419 |
|
|
[74] (これでもまだ [CODE(ABNF)[dot-atom-text]] が quote あり/なし2種類で表せるなあ。) |
| 420 |
|
|
[[#comment]] |
| 421 |
|
|
|
| 422 |
|
|
|
| 423 |
|
|
* encoded-word と quoted-string |
| 424 |
|
|
|
| 425 |
|
|
[75] [[MIME]] の [[encoded-word]] は、 [[RFC2047]] (やその以前の RFC) |
| 426 |
|
|
によれば [CODE(ABNF)[quoted-string]] の内側 ([CODE(ABNF)[qcontent]]) |
| 427 |
|
|
で使うことは出来ません。ですから、 [SAMP["=?us-ascii?q?foo?="]] |
| 428 |
|
|
は [CODE(ABNF)[encoded-word]] を含む [CODE(ABNF)[quoted-string]] |
| 429 |
|
|
のように見えますが、単なる [SAMP[=?us-ascii?q?foo?=]] |
| 430 |
|
|
という文字列であって、 [SAMP[foo]] の [CODE(ABNF)[encoded-word]] |
| 431 |
|
|
では'''ありません'''。 |
| 432 |
|
|
|
| 433 |
|
|
[76] >>75 なのですが、 [[M$OE]] |
| 434 |
|
|
のようなふざけた[[利用者エージェント]]が長く間違った利用を続けていたこともあって、[[バグ互換性]]のためにこの方法を使う |
| 435 |
|
|
[[UA]] は多いです。 |
| 436 |
|
|
- [80] [[HTTP]] では [CODE(ABNF)[quoted-string]] 中で [CODE(ABNF)[encoded-word]] が使えます。 [[encoded-word]>>13] を参照。 |
| 437 |
|
|
[[#comment]] |
| 438 |
|
|
|
| 439 |
|
|
|
| 440 |
|
|
* パラメーター値である quoted-string |
| 441 |
|
|
|
| 442 |
|
|
[77] [[MIME]] が [[Content-Type:欄]]などで導入した [[prameter]] |
| 443 |
|
|
では、値の部分 ([[ABNF]] でいう [[value]]) |
| 444 |
|
|
を [[token]] 又は [CODE(ABNF)[quoted-string]] としています。 |
| 445 |
|
|
つまり、特殊文字が値に使われる場合には [CODE(ABNF)[quoted-string]] |
| 446 |
|
|
が使われ (るか、後に導入された [[RFC2231]] の [[MIMEのparameter値拡張]]が使われ) ます。 |
| 447 |
|
|
この方法は [[HTTP]] の一部の欄や [[usefor-article]] |
| 448 |
|
|
などの MIME に倣った幾つかの仕様でも採用されています。 |
| 449 |
|
|
|
| 450 |
|
|
[78] RFC 2231 による拡張の導入は MIME 本体より遅れ、未だにその存在を知らない人もいるくらいで、 |
| 451 |
|
|
>>75 のような [CODE(ABNF)[encoded-word]] を使った例や、 [[シフトJIS]] |
| 452 |
|
|
などを (規格に反して) 直書きする実装が多く存在しています。 |
| 453 |
|
|
特に [[Content-Disposition:欄]]の [CODE[filename]] パラメーターで問題となっています。 |
| 454 |
|
|
|
| 455 |
|
|
[79] >>78 また、 RFC 2231 の方法の標準化以前に制定された規格ではこの方法を規定してしまったものもあります。 |
| 456 |
|
|
([[MIMEのparameter値拡張]>>3]) |
| 457 |
|
|
|
| 458 |
|
|
|
| 459 |
|
|
* RFC の部分の License |
| 460 |
|
|
|
| 461 |
|
|
- [11] [[RFCのライセンス]] |
| 462 |
|
|
|
| 463 |
|
|
|
| 464 |
|
|
* メモ |
| 465 |
|
|
|
| 466 |
|
|
[83] |
| 467 |
|
|
[[RFC 5335]] により、 [CODE(MIME)@en[[[message/global]]]] |
| 468 |
|
|
においては [CODE(ABNF)@en[[[quoted-string]]]] 中で |
| 469 |
|
|
[[UTF-8]] の使用が認められるようになりました ([[RFC 5335]] 4.3)。 |
| 470 |
|
|
|
| 471 |
|
|
([[名無しさん]]) |
| 472 |
|
|
|
| 473 |
|
|
[84] |
| 474 |
|
|
(正確には [CODE(ABNF)@en[[[utf8-quoted-string]]]]) |
| 475 |
|
|
([[名無しさん]]) |
| 476 |
|
|
|