Skip to content

Commit

Permalink
Validator rollup (ampproject#19426)
Browse files Browse the repository at this point in the history
* cl/221331004 Simplify FORM.

* cl/221678254 Relax attribute blacklisted_value_regex to only match values before urlescaping.

* cl/221691892 Media query spec for amp4email.

* cl/221808630 Revision bump for ampproject#18188

* cl/221824133 Remove validator support for the deprecated boilerplate CSS.

* cl/222112581 Revision bump for ampproject#19285
  • Loading branch information
Gregable authored and Enriqe committed Nov 28, 2018
1 parent 3a74658 commit 9fa7ea5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 53 deletions.
3 changes: 1 addition & 2 deletions validator/engine/validator.js
Expand Up @@ -3981,10 +3981,9 @@ function validateAttributes(
}
}
if (attrSpec.blacklistedValueRegex !== null) {
const decodedAttrValue = decodeAttrValue(attr.value);
const regex = context.getRules().getPartialMatchCaseiRegex(
attrSpec.blacklistedValueRegex);
if (regex.test(attr.value) || regex.test(decodedAttrValue)) {
if (regex.test(attr.value)) {
context.addError(
amp.validator.ValidationError.Code.INVALID_ATTR_VALUE,
context.getLineCol(),
Expand Down
Expand Up @@ -28,9 +28,11 @@ FAIL
| <link rel="canonical" href="./regular-html-version.html">
| <meta name="viewport" content="width=device-width,minimum-scale=1">
| <style>body {opacity: 0}</style>
>> ^~~~~~~~~
feature_tests/deprecation_warnings_and_errors.html:29:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <noscript><style>body {opacity: 1}</style></noscript>
>> ^~~~~~~~~
feature_tests/deprecation_warnings_and_errors.html:30:12 The tag 'noscript > style[amp-boilerplate] - old variant' is deprecated - use 'noscript > style[amp-boilerplate]' instead. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [DEPRECATION]
feature_tests/deprecation_warnings_and_errors.html:30:12 The parent tag of tag 'style amp-custom' is 'noscript', but it can only be 'head'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| </head>
| <body>
Expand All @@ -39,3 +41,7 @@ feature_tests/deprecation_warnings_and_errors.html:30:12 The tag 'noscript > sty
feature_tests/deprecation_warnings_and_errors.html:34:0 The tag 'disallowed-tag' is disallowed. [DISALLOWED_HTML]
| </body>
| </html>
>> ^~~~~~~~~
feature_tests/deprecation_warnings_and_errors.html:36:6 The mandatory tag 'head > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
>> ^~~~~~~~~
feature_tests/deprecation_warnings_and_errors.html:36:6 The mandatory tag 'noscript > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
Expand Up @@ -28,7 +28,7 @@ FAIL
| <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
| <noscript><style>body {opacity: 1}</style></noscript>
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed.html:28:12 The tag 'noscript > style[amp-boilerplate] - old variant' is deprecated - use 'noscript > style[amp-boilerplate]' instead. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [DEPRECATION]
feature_tests/new_and_old_boilerplate_mixed.html:28:12 The parent tag of tag 'style amp-custom' is 'noscript', but it can only be 'head'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| </head>
| <body>
Expand All @@ -37,3 +37,5 @@ feature_tests/new_and_old_boilerplate_mixed.html:28:12 The tag 'noscript > style
| </html>
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed.html:34:6 The tag 'noscript > style[amp-boilerplate]' is missing or incorrect, but required by 'head > style[amp-boilerplate]'. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [GENERIC]
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed.html:34:6 The mandatory tag 'noscript > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
Expand Up @@ -27,6 +27,8 @@ FAIL
| <link rel="canonical" href="./regular-html-version.html">
| <meta name="viewport" content="width=device-width,minimum-scale=1">
| <style>body {opacity: 0}</style>
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed2.html:28:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| </head>
Expand All @@ -36,3 +38,5 @@ FAIL
| </html>
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed2.html:35:6 The tag 'head > style[amp-boilerplate]' is missing or incorrect, but required by 'noscript > style[amp-boilerplate]'. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [GENERIC]
>> ^~~~~~~~~
feature_tests/new_and_old_boilerplate_mixed2.html:35:6 The mandatory tag 'head > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
10 changes: 8 additions & 2 deletions validator/testdata/feature_tests/old-boilerplate.out
@@ -1,4 +1,4 @@
PASS
FAIL
| <!--
| Copyright 2017 The AMP HTML Authors. All Rights Reserved.
|
Expand All @@ -23,8 +23,10 @@ PASS
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
| <link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
| <style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
>> ^~~~~~~~~
feature_tests/old-boilerplate.html:24:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
>> ^~~~~~~~~
feature_tests/old-boilerplate.html:24:44 The tag 'noscript > style[amp-boilerplate] - old variant' is deprecated - use 'noscript > style[amp-boilerplate]' instead. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [DEPRECATION]
feature_tests/old-boilerplate.html:24:44 The parent tag of tag 'style amp-custom' is 'noscript', but it can only be 'head'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| </head>
| <body>
Expand All @@ -36,3 +38,7 @@ feature_tests/old-boilerplate.html:24:44 The tag 'noscript > style[amp-boilerpla
| </p>
| </body>
| </html>
>> ^~~~~~~~~
feature_tests/old-boilerplate.html:35:6 The mandatory tag 'head > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
>> ^~~~~~~~~
feature_tests/old-boilerplate.html:35:6 The mandatory tag 'noscript > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
8 changes: 5 additions & 3 deletions validator/testdata/feature_tests/regexps.out
Expand Up @@ -27,7 +27,7 @@ FAIL
| <meta name="viewport" content="width=device-width,minimum-scale=1">
| <style>invalid body</style>
>> ^~~~~~~~~
feature_tests/regexps.html:27:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/guides/author-develop/responsive/style_pages) [DISALLOWED_HTML]
feature_tests/regexps.html:27:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
| <noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
| <script async src="https://cdn.ampproject.org/v0.js"></script>
|
Expand Down Expand Up @@ -147,7 +147,7 @@ feature_tests/regexps.html:111:2 The attribute 'name' in tag 'meta name= and con
| -->
| <style amp-custom>
>> ^~~~~~~~~
feature_tests/regexps.html:117:2 The text inside tag 'style amp-custom' contains 'CSS i-amphtml- name prefix', which is disallowed. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [AUTHOR_STYLESHEET_PROBLEM]
feature_tests/regexps.html:117:2 The tag 'style amp-custom' appears more than once in the document. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
| .comic-amp-font-loaded .comic-amp {
| font-family: 'Comic AMP', serif, sans-serif;
| }
Expand Down Expand Up @@ -205,4 +205,6 @@ feature_tests/regexps.html:154:2 The attribute 'name' in tag 'input' is set to t
>> ^~~~~~~~~
feature_tests/regexps.html:157:6 The tag 'head > style[amp-boilerplate]' is missing or incorrect, but required by 'noscript > style[amp-boilerplate]'. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [GENERIC]
>> ^~~~~~~~~
feature_tests/regexps.html:157:6 The extension 'amp-hulu' was found on this page, but is unused. Please remove this extension. [AMP_TAG_PROBLEM]
feature_tests/regexps.html:157:6 The extension 'amp-hulu' was found on this page, but is unused. Please remove this extension. [AMP_TAG_PROBLEM]
>> ^~~~~~~~~
feature_tests/regexps.html:157:6 The mandatory tag 'head > style[amp-boilerplate]' is missing or incorrect. (see https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md) [MANDATORY_AMP_TAG_MISSING_OR_INCORRECT]
2 changes: 1 addition & 1 deletion validator/testdata/feature_tests/style_tag.out
Expand Up @@ -30,7 +30,7 @@ FAIL
|
| <style></style>
>> ^~~~~~~~~
feature_tests/style_tag.html:30:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/guides/author-develop/responsive/style_pages) [DISALLOWED_HTML]
feature_tests/style_tag.html:30:2 The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'. (see https://www.ampproject.org/docs/reference/spec#stylesheets) [DISALLOWED_HTML]
|
| </head>
| <body>
Expand Down
2 changes: 0 additions & 2 deletions validator/testdata/feature_tests/urls.out
Expand Up @@ -214,8 +214,6 @@ feature_tests/urls.html:113:2 The attribute 'src' in tag 'amp-pixel' is set to t
>> ^~~~~~~~~
feature_tests/urls.html:114:2 The attribute 'src' in tag 'amp-video' is set to the invalid value '__amp_source_origin'. (see https://www.ampproject.org/docs/reference/components/amp-video) [DISALLOWED_HTML]
| <amp-video src="%5f_amp_source%5forigin" width="42" height="42"></amp-video>
>> ^~~~~~~~~
feature_tests/urls.html:115:2 The attribute 'src' in tag 'amp-video' is set to the invalid value '%5f_amp_source%5forigin'. (see https://www.ampproject.org/docs/reference/components/amp-video) [DISALLOWED_HTML]
| </body>
| </html>
>> ^~~~~~~~~
Expand Down
52 changes: 11 additions & 41 deletions validator/validator-main.protoascii
Expand Up @@ -26,7 +26,7 @@ min_validator_revision_required: 348
# newer versions of the spec file. This is currently a Google internal
# mechanism, validator.js does not use this facility. However, any
# change to this file (validator-main.js) requires updating this revision id.
spec_file_revision: 767
spec_file_revision: 772

styles_spec_url: "https://www.ampproject.org/docs/guides/author-develop/responsive/style_pages"
script_spec_url: "https://www.ampproject.org/docs/reference/spec#html-tags"
Expand Down Expand Up @@ -1067,6 +1067,16 @@ tags: { # Special custom 'author' spreadsheet for AMP
at_rule_spec: {
name: 'media'
type: PARSE_AS_RULES
media_query_spec: {
issues_as_error: true
type: 'all'
type: 'screen'
feature: 'device-width'
feature: 'orientation'
feature: 'pointer'
feature: 'resolution'
feature: 'width'
}
}
at_rule_spec: {
name: 'page'
Expand Down Expand Up @@ -1097,45 +1107,6 @@ tags: { # Special custom 'author' spreadsheet for AMP
}
spec_url: "https://www.ampproject.org/docs/reference/spec#stylesheets"
}
tags: {
html_format: AMP
html_format: EXPERIMENTAL
tag_name: "STYLE"
spec_name: "head > style[amp-boilerplate] - old variant"
mandatory_alternatives: "head > style[amp-boilerplate]"
unique: true
mandatory_parent: "HEAD"
# Special Case. This tag is deprecated, however this matches any <style> tag
# in the document head without an associated attribute. This is far more
# likely to happen to be caused by the user intending to use
# <style amp-custom> than having used a deprecated amp-boilerplate. So, for
# this case, we do not emit deprecation warnings. Note that the <noscript>
# component of the deprecated boilerplate will still emit a deprecation
# warning. See https://github.com/ampproject/amphtml/issues/4421
#deprecation: "head > style[amp-boilerplate]"
#deprecation_url: "https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md"
attrs: { name: "nonce" }
cdata: {
cdata_regex: "body ?{opacity: ?0}"
}
spec_url: "https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md"
}
tags: {
html_format: AMP
tag_name: "STYLE"
spec_name: "noscript > style[amp-boilerplate] - old variant"
mandatory_alternatives: "noscript > style[amp-boilerplate]"
unique: true
mandatory_parent: "NOSCRIPT"
mandatory_ancestor: "HEAD"
deprecation: "noscript > style[amp-boilerplate]"
deprecation_url: "https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md"
attrs: { name: "nonce" }
cdata {
cdata_regex: "body ?{opacity: ?1}"
}
spec_url: "https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md"
}
tags: {
html_format: AMP
html_format: EXPERIMENTAL
Expand Down Expand Up @@ -3738,7 +3709,6 @@ tags { # <form method=GET ...>
tags { # <form method=POST ...>
html_format: AMP
html_format: AMP4ADS
html_format: EXPERIMENTAL
tag_name: "FORM"
spec_name: "FORM [method=POST]"
requires_extension: "amp-form"
Expand Down

0 comments on commit 9fa7ea5

Please sign in to comment.