-
Notifications
You must be signed in to change notification settings - Fork 4
/
553.txt
284 lines (213 loc) · 13.7 KB
/
553.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
* 提出 (Web Forms)
[1]
[[フォーム]]を[DFN[[RUBYB[提出] [submit]]]]すると、
[[成功]]制御子の[[制御子名]]と[[現在値]]の組が[[フォーム処理エージェント]]に渡されます。 [SRC[HTML 4 17.2, 17.13]]
[2] 仕様書:
- [[HTML 4]] ([[Web Forms 1.0]])
-- [CITE[17.13 Form submission]]
<IW:HTML4:"interact/forms.html#submit-format">
- [[Web Forms 2.0]]
-- [CSECTION@en[1.12. Security]]
<IW:WF2:"#security">
-- <http://www.whatwg.org/specs/web-forms/current-work/#form-submission>
** 提出処理の流れ
[4] フォームの提出は、次の手順を経ます。 [SRC[HTML 4 17.13.3]]
:1. 成功制御子の識別:[[フォーム]]内の制御子から、[[成功]]しているものを選びます。
:2. フォーム・データ集合の構築:成功制御子から、[DFN[[[フォーム・データ集合]]]]
([[制御子名]]と[[現在値]]の組の集合) を構築します。
:3. フォーム・データ集合の符号化:フォーム・データ集合を指定された[[媒体型]]
([CODE(HTMLa)[[[enctype]]]]) により符号化します。
:4. 符号化フォーム・データ集合の提出:符号化したデータ集合を指定された[[フォーム処理エージェント]]
([CODE(HTMLa)[[[action]]]]) に指定された方法 ([CODE(HTMLa)[[[method]]]])
で送信します。
:(5. 結果のレンダリング):UA は、提出の際の HTTP [CODE(HTTP)[[[GET]]]]・[CODE(HTTP)[[[POST]]]]
に対する応答をレンダリングするべきです。
[5] >>4 で、提出されるのがフォーム・データ集合 (名前と現在値の組の集合)
だけのように書かれていますが、
ファイル選択制御子の場合はそれに含まれないはずのファイルの内容も提出されます。
画像提出ボタン ([[[CODE(HTMLe)[input]]//[CODE(HTML)[image]]]])
の座標との関係も不明確で、概念の整理が不十分という印象を受けます。
[6] なお、 >>4 の流れは、4つの段階を完全に別のものとして扱えるわけではなく、
制御子の種類, 媒体型, 処理エージェントのプロトコルなどの依存関係があります。
仕様や実装によって実際に使用できる組合せは限られてきます。
>>7 をご覧ください。
[9]
文章入力制御子の入力長制御を完全に行えないなど、環境の事情によっては提出の際に
[CODE(HTMLa)[[[maxlength]]]] 属性に基づく検査が必要かもしれません。
(UA の実装方法によっては、[[初期値]]が [CODE(HTMLa)[maxlength]] を満たさない場合やスクリプトによる変更があった場合にも注意が必要です。)
([[名無しさん]])
[[#comment]]
** 提出方法
[7]
HTML 4 が[Q[確立された慣習]]として対応することを要求している
[SRC[HTML 4 17.13.3, 17.13.4]] のは、次の場合だけです。
,[CODE(HTMLa)[action]] ,[CODE(HTMLa)[method]] ,[CODE(HTMLa)[enctype]] ,その他
,[[HTTP]] URI ,[CODE(HTML)[[[get]]]] ,[CODE(MIME)[[[application/x-www-form-urlencoded]]]] ,フォーム・データは ASCII 文字のみ
,HTTP URI ,[CODE(HTML)[[[post]]]] ,[CODE(MIME)[[[application/x-www-form-urlencoded]]]] ,フォーム・データは ASCII 文字のみ
,HTTP URI ,[CODE(HTML)[[[post]]]] ,[CODE(MIME)[[[multipart/form-data]]]]
これも含めて、様々な組合せが利用されています。
使用例のある URI scheme:
- [CODE(URI)[[[http]]:]] (HTTP)
- [CODE(URI)[[[https]]:]] (HTTP over [[TLS]])
- [CODE(URI)[[[file]]:]] (ファイル)
- [CODE(URI)[[[mailto]]:]] (電子メイル)
- [CODE(URI)[[[data]]:]] (データ)
- [CODE(URI)[[[ftp]]:]] ([[FTP]])
- [CODE(URI)[[[sms]]:]] ([[SMS]])
- [CODE(URI)[[[smsto]]:]] ([[SMS]])
- [CODE(URI)[[[javascript]]:]] ([[ECMAScript]])
- [CODE(URI)[[[device]]:]] (装置)
- [CODE(URI)@en[[[location]]:]] ([[位置情報]]付き [[HTTP]])
[25] 使用例のある媒体型:
[FIG(short list)[
- [CODE(MIME)[[[application/x-www-form-urlencoded]]]]
- [CODE(MIME)[[[application/sgml-form-urlencoded]]]]
- [CODE(MIME)[[[application/x-www-form+xml]]]]
- [CODE(MIME)[[[text/plain]]]]
- [CODE(MIME)[[[multipart/form-data]]]]
- [CODE(MIME)[[[application/vnd.wap.multipart.form-data]]]]
-
[11]
[CODE(MIME)[[[application/vnd.wap.wml.form.urlencode]]]]
- [20] [CODE(MIME)@en[[[application/x-w3-isindex]]]]
[SRC@en[[[Emacs/W3]]]]
- [21] [CODE(MIME)@en[[[application/w-www-form-data]]]]
[SRC@en[[[Emacs/W3]]]]
- [23] [CODE(MIME)@en[[[application/x-gopher-query]]]]
[SRC@en[[[Emacs/W3]]]]
- [24] [CODE(MIME)@en[[[application/gopher-ask-block]]]]
[SRC@en[[[Emacs/W3]]]]
]FIG]
;; [26] [[フォームデータ集合]]に使われる [[MIME型]]の一覧は、
[REFS[
- [27] [CITE@en[data-web-defs/mime-types.txt at master · manakai/data-web-defs]] ([TIME[2015-04-11 20:50:07 +09:00]] 版) <https://github.com/manakai/data-web-defs/blob/master/doc/mime-types.txt>
]REFS]
... にも「[CODE[form_data]]」欄として含まれています。
* 安全性
[14]
[[フォーム]]の[[提出]]機能が濫用され、
[[利用者]]に第3者を攻撃させるために使われることがあります。
例えば、 [[SMTP]] [[鯖]]を[[提出]]先とし、
[[提出]]により[[利用者]]が気づかない間に [[spam]]
が[[送信]]されてしまうことがあるかもしれません。
[[SMTP]] や [[telnet]] などよく知られた[[フォーム]][[提出]]には使われない[[プロトコル]]の[[ポート]]番号が[[提出]]先に指定されている時には、
[[提出]]を制限することが勧められています。
[SRC@en[WF2 1.12]]
[15]
> Certain actions, including submitting a form to a third-party site and making HTTP GET requests to remote sites (both of which would be blind attacks, assuming the UA implements a cross-domain scripting security mechanism) have been historically allowed, and many sites depend on these features for quite legitimate uses. User agents should allow them.
> Servers therefore must also consider security. Servers should never perform non-idempotent actions in response to GET requests, as discussed by the HTTP specification. Servers should also check the Referer header to ensure that only requests from trusted hosts are honoured.
> Servers should also consider the client to be untrusted, since in most scenarios requests can be made to hosts by hostile parties directly, bypassing any security logic included in the page nominally intended to perform the submission. Thus servers should perform validation on all submitted data, whether such validation is expected to be performed on the client or not.
[SRC@en[WF2 1.12]]
[[#comment]]
** 実装
[8] [WEAK[2003-10-12 12:52:32 +00:00]] ''[[名無しさん]]'': 手元の
[Q[Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.4) Gecko/20030624]]
で試してみたら、 [CODE(HTMLa)[[[enctype]]]] は
[CODE(MIME)[[[application/x-www-form-urlencoded]]]] と
[CODE(MIME)[[[text/plain]]]] と [CODE(MIME)[[[multipart/form-data]]]]
に対応していましたが、[[引数]]をつけたら全滅でした。
[2] >>1 [[WinIE 6]] と Win[[Opera]] 7.20 でも同様でした。但し Opera は
[CODE(MIME)[text/plain]] に対応していない模様。
[[#comment]]
** メモ
[3] フォームの[Q[提出]] ([Q[submit]]) は、意味を解して[Q[送信]]とも呼ばれます。
しかしながら、提出と送信ではニュアンスが異なりますから、
専門用語としては使い分けるべきでしょう。
[10]
[[WAP 2.0]] は [[XHTML m12n]] + α ですが、
追加の属性の関係でフォーム処理の方法を修正しています。
[12]
[[ヘブライ語]]が含まれるかもしれない時に [CODE(HTML)[[[get]]]]
を [CODE(HTMLa)[[[method]]]] に使うのは非推奨です。
- [[SI 4281]]:1998
-- [CSECTION[8.1 Encoding the reply]]
<http://www.qsm.co.il/Hebrew/si4281e.htm>
[13]
[[提出]]先[[URI]] ([CODE(HTMLa)@en[[[action]]]] [[URI]])
に既に[CODE(URI)@en[?]]が含まれているにもかかわらず[[提出]]方法が[[HTTP]] [CODE(HTML)@en[[[get]]]]の場合どうするかについて、
- [[HTML 4]]には規定がありません。
- [[Web Forms 2.0]]と実際の[[Webブラウザ]]は[CODE(URI)@en[?]]以後を切り落とした上で[[フォーム・データ集合]]から生成したものを付け足します。
- [[XForms 1.0]]はそのままの[[URI]]に、[CODE(URI)@en[&]]と[[フォーム・データ集合]]から生成したものを付け足します。
[[Web Forms 2.0]]の方法は、[[相対URI参照]]を使ってもどんどん[CODE(ABNF)@en[[[query]]]]が長くなっていく虞が無いという利点があります。
[CITE@en[Re: Compatibility between HTML, XForms, and WSDL from Ian Hickson on 2005-03-21 (www-forms-editor@w3.org from March 2005)]]
<http://lists.w3.org/Archives/Public/www-forms-editor/2005Mar/0008.html>
[16]
[CITE[公開メモ日記 - IEのフォームでsubmitボタンの値が送信されるかどうか]] <http://knoa.jp/memo/?id=2006-07-18+17:26>
([[名無しさん]] [WEAK[2006-07-18 12:02:21 +00:00]])
[17]
[CITE[Form Submission by Pressing the Enter Key]] <http://suika.fam.cx/~wakaba/-temp/test/html/form/submission/submit-by-enter-1.html>
[CITE[Form Submission by Pressing the Enter Key]] <http://suika.fam.cx/~wakaba/-temp/test/html/form/submission/submit-by-enter-2.html>
[18]
[CITE[Web Forms 2.0]] <http://www.whatwg.org/specs/web-forms/current-work/#enter-submit>
[19]
>>16-18
[[WinIE 6]] では、[[テキスト入力制御子]]で [KEY@en[[[Enter]]]]
を押すと、
- [[テキスト入力制御子]]が[[フォーム]]内に1つなら、
[[提出]][[ボタン]]を押して''いない''として[[提出]]
- [[テキスト入力制御子]]が[[フォーム]]内に2つ以上なら、
[[提出]][[ボタン]]を押し''た''として[[提出]]
[[Firefox 1.5]] と [[Opera 8]] では、どちらも押し''た''として[[提出]]
([[名無しさん]] [WEAK[2006-07-18 12:05:24 +00:00]])
[22]
[CITE@en-GB[FORM submission and i18n]] ([CODE[2006-05-19 20:53:32 +09:00]] 版)
<http://ppewww.physics.gla.ac.uk/~flavell/charset/form-i18n.html>
[[#comment]]
* メモ
[298] [CITE@ja[フォームの入力エラーを吹き出しで教えてくれる JavaScript]] ([[Kyosuke Takayama]] 著, [TIME[2008-12-31 22:40:11 +09:00]] 版) <http://espion.just-size.jp/archives/07/035231221.html>
[299] [CITE@en[Web Applications 1.0 r5566 Put method=DELETE and method=PUT to rest.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10671]]
( ([TIME[2010-09-30 16:58:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5565&to=5566>
[300] [CITE[''''''[''''''whatwg'''''']'''''' HTMLForms: Implicit Submission with {display:none} button]]
( ([TIME[2011-09-24 09:56:23 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-September/033285.html>
[301] [CITE[''''''[''''''whatwg'''''']'''''' HTMLForms: Implicit Submission with {display:none} button]]
( ([TIME[2012-04-04 07:52:15 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-February/034924.html>
[302] [CITE@en[Web Applications 1.0 r7992 Make <form> submission more like reality.]]
( ([TIME[2013-06-20 06:37:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7991&to=7992>
[303] [CITE@en[W3C HTML JSON form submission]]
( ([TIME[2014-12-09 19:38:36 +09:00]] 版))
<http://darobin.github.io/formic/specs/json/>
[304] [CITE@en[W3C HTML JSON form submission]]
( ([TIME[2014-05-27 23:38:45 +09:00]] 版))
<http://www.w3.org/TR/html-json-forms/>
[305] [CITE@en[W3C HTML JSON form submission]]
( ([TIME[2014-05-27 23:38:45 +09:00]] 版))
<http://www.w3.org/TR/2014/WD-html-json-forms-20140529/>
[306] [CITE@en[darobin/formic]]
( ([TIME[2014-12-25 14:28:07 +09:00]] 版))
<https://github.com/darobin/formic>
[28] [CITE@en[Integrate Fetch into HTML · whatwg/html@7c5555a]]
([TIME[2015-09-18 19:15:54 +09:00]] 版)
<https://github.com/whatwg/html/commit/7c5555a16f2920c02244c10756bb2f1a11e87a22>
[FIG(quote)[
[FIGCAPTION[
[29] [CITE@en[W3C HTML JSON form submission]]
([TIME[2015-09-29 04:06:11 +09:00]] 版)
<http://www.w3.org/TR/2015/NOTE-html-json-forms-20150929/>
]FIGCAPTION]
> This specification is no longer in active maintenance and the HTML Working Group does not intend to maintain it further.
]FIG]
[30] [CITE@en[Remove allow non-ASCII-compatible encodings flag · whatwg/html@c485b70]]
([TIME[2016-02-10 21:55:07 +09:00]] 版)
<https://github.com/whatwg/html/commit/c485b70bfe41ed1302c451bc62b58df80cffd325>
[31] [CITE@en[Let the URL Standard deal with application/x-www-form-urlencoded · whatwg/html@0fef169]]
([TIME[2016-02-11 11:43:29 +09:00]] 版)
<https://github.com/whatwg/html/commit/0fef169e6fca7433e3aac2a3640b4665b791ff8e>
[32] [CITE@en[Update integration with Encoding Standard · whatwg/html@6a31c26]]
([TIME[2016-02-14 18:48:50 +09:00]] 版)
<https://github.com/whatwg/html/commit/6a31c26cf12e39dab1a488e75dd56c03d6786d39>
[33] [CITE@en[Remove <isindex> and <input name=isindex> · whatwg/html@5c44abc]]
([TIME[2016-04-25 17:28:08 +09:00]] 版)
<https://github.com/whatwg/html/commit/5c44abc734eb483f9a7ec79da5844d2fe63d9c3b>
[34] [CITE@en[Fix form submission for the data URL scheme]]
( ([[annevk]]著, [TIME[2016-05-27 17:47:54 +09:00]]))
<https://github.com/whatwg/html/commit/e2d80d9285976c6c38bda188c59e97456006d0a3>
[35] [CITE@en[Clean up language around form submission and URLs]]
( ([[annevk]]著, [TIME[2016-05-27 17:54:39 +09:00]]))
<https://github.com/whatwg/html/commit/69ea9df17bf1d7d70a2014c6d2aaf16670683feb>
[36] [CITE@en[Fix form submission's encoding algorithms]]
( ([[annevk]]著, [TIME[2016-05-30 23:15:22 +09:00]]))
<https://github.com/whatwg/html/commit/ec42efb1d7c3a2e34db21b8076a8a3f4bd6dfb81>