Skip to content

Commit

Permalink
Allow input[type=image]. (#37651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Grothaus committed Feb 11, 2022
1 parent 6f88c91 commit dc411f8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
Expand Up @@ -55,7 +55,7 @@ amp-story/1.0/test/validator-amp-story-form-error.html:42:10 The attribute 'form
| <!-- Image input types are not allowed. -->
| <input type="image">
>> ^~~~~~~~~
amp-story/1.0/test/validator-amp-story-form-error.html:45:10 The attribute 'type' in tag 'input' is set to the invalid value 'image'. (see https://amp.dev/documentation/components/amp-form/)
amp-story/1.0/test/validator-amp-story-form-error.html:45:10 The tag 'input' may only appear as a descendant of tag 'form [method=post]'. (see https://amp.dev/documentation/components/amp-form/)
|
| <!-- Password input types are only allowed when the form element's method is POST. -->
| <input type="password">
Expand Down
4 changes: 2 additions & 2 deletions validator/testdata/feature_tests/forms.html
Expand Up @@ -120,9 +120,9 @@
<option value="1">English</option>
</select>
<textarea name="comment"></textarea>
<!-- Invalid: input can not be type="image". -->
<!-- Valid: input can be type="image". -->
<form method="post" action-xhr="https://example.com/subscribe" target="_blank">
<input type="image" name="image">
<input type="image" name="image" src="https://site.example/image.example">
</form>
<!-- Valid: input can be type="password" or type="file" in a post xhr form. -->
<form method="post" action-xhr="https://example.com/subscribe" target="_blank">
Expand Down
6 changes: 2 additions & 4 deletions validator/testdata/feature_tests/forms.out
Expand Up @@ -125,11 +125,9 @@ feature_tests/forms.html:114:2 The attribute 'target' in tag 'form' is set to th
| <option value="1">English</option>
| </select>
| <textarea name="comment"></textarea>
| <!-- Invalid: input can not be type="image". -->
| <!-- Valid: input can be type="image". -->
| <form method="post" action-xhr="https://example.com/subscribe" target="_blank">
| <input type="image" name="image">
>> ^~~~~~~~~
feature_tests/forms.html:125:4 The attribute 'type' in tag 'input' is set to the invalid value 'image'. (see https://amp.dev/documentation/components/amp-form/)
| <input type="image" name="image" src="https://site.example/image.example">
| </form>
| <!-- Valid: input can be type="password" or type="file" in a post xhr form. -->
| <form method="post" action-xhr="https://example.com/subscribe" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions validator/testdata/feature_tests/leaks.out
Expand Up @@ -144,7 +144,7 @@ feature_tests/leaks.html:90:0 The attribute 'longdesc' may not appear in tag 'im
| -->
| <input type="image" src="https://leaking.via/input-src" name="test" value="test">
>> ^~~~~~~~~
feature_tests/leaks.html:96:0 The attribute 'src' may not appear in tag 'input'. (see https://amp.dev/documentation/components/amp-form/)
feature_tests/leaks.html:96:0 The tag 'input' may only appear as a descendant of tag 'form [method=post]'. (see https://amp.dev/documentation/components/amp-form/)
| <isindex src="https://leaking.via/isindex-src" type="image">
>> ^~~~~~~~~
feature_tests/leaks.html:97:0 The tag 'isindex' is disallowed.
Expand Down Expand Up @@ -364,4 +364,4 @@ feature_tests/leaks.html:203:0 The tag 'vmlframe' is disallowed.
| </vmlframe>
|
| </body>
| </html>
| </html>
2 changes: 1 addition & 1 deletion validator/testdata/feature_tests/leaks.out.cpponly
Expand Up @@ -144,7 +144,7 @@ feature_tests/leaks.html:90:0 The attribute 'longdesc' may not appear in tag 'im
| -->
| <input type="image" src="https://leaking.via/input-src" name="test" value="test">
>> ^~~~~~~~~
feature_tests/leaks.html:96:0 The attribute 'src' may not appear in tag 'input'. (see https://amp.dev/documentation/components/amp-form/)
feature_tests/leaks.html:96:0 The tag 'input' may only appear as a descendant of tag 'form [method=post]'. (see https://amp.dev/documentation/components/amp-form/)
| <isindex src="https://leaking.via/isindex-src" type="image">
>> ^~~~~~~~~
feature_tests/leaks.html:97:0 The tag 'isindex' is disallowed.
Expand Down
29 changes: 29 additions & 0 deletions validator/validator-main.protoascii
Expand Up @@ -2942,6 +2942,35 @@ tags: {
mandatory_ancestor: "FORM [method=POST]"
spec_url: "https://amp.dev/documentation/components/amp-form/"
}
tags: {
html_format: AMP
tag_name: "INPUT"
spec_name: "INPUT [type=image]"
attrs: {
name: "type"
value_casei: "image"
mandatory: true
dispatch_key: NAME_VALUE_DISPATCH
}
attrs: {
disabled_by: "amp4email"
name: "[type]"
}
attrs: {
name: "src"
mandatory: true
value_url: {
protocol: "data"
protocol: "http"
protocol: "https"
}
disallowed_value_regex: "__amp_source_origin"
}
attr_lists: "input-common-attr"
attr_lists: "name-attr"
mandatory_ancestor: "FORM [method=POST]"
spec_url: "https://amp.dev/documentation/components/amp-form/"
}
# 4.10.6 The button element
tags: {
html_format: AMP
Expand Down

0 comments on commit dc411f8

Please sign in to comment.