Skip to content

Commit

Permalink
Validator rollup (#7137)
Browse files Browse the repository at this point in the history
* Make tagSpecById array; add comment about ids. Remove unused type decl.

* Allow SRI attributes for stylesheets.

* Object<number, x> -> Array<x> and remove extensionUnusedUnless...

* Construct ParsedAttrSpec objects lazily.

* Generate a synthetic field ValidatorRules.dispatchKeyByTagSpecId and populate it.

* Make the ParsedTagSpec instantiation lazy.

* Reduce greediness of i-amphtml- blacklist regex.

* More disallowed id and name attribute values.

* Allow `nonce` attribute on <script> and <style> tags.

* Make validator protoascii usage more consistent.

* Allow async attr on font link tag.

* Allow <meta http-equiv=origin-trial ...>
  • Loading branch information
honeybadgerdontcare committed Jan 20, 2017
1 parent 3bdb2f7 commit d17e7e2
Show file tree
Hide file tree
Showing 56 changed files with 435 additions and 197 deletions.
2 changes: 2 additions & 0 deletions extensions/amp-access/0.1/validator-amp-access.protoascii
Expand Up @@ -31,6 +31,7 @@ tags: { # amp-access
value: "amp-access"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down Expand Up @@ -62,6 +63,7 @@ tags: { # amp-access (json)
value: "amp-access"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "type"
mandatory: true
Expand Down
Expand Up @@ -32,6 +32,7 @@ tags: { # amp-accordion
value: "amp-accordion"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/0.1/validator-amp-ad.protoascii
Expand Up @@ -37,6 +37,7 @@ tags: { # amp-ad
value: "amp-ad"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
13 changes: 8 additions & 5 deletions extensions/amp-analytics/0.1/validator-amp-analytics.protoascii
Expand Up @@ -41,6 +41,7 @@ tags: { # amp-analytics
value: "amp-analytics"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -64,6 +65,7 @@ tags: { # amp-analytics (json)
tag_name: "SCRIPT"
spec_name: "amp-analytics extension .json script"
mandatory_parent: "AMP-ANALYTICS"
attrs: { name: "nonce" }
attrs: {
name: "type"
mandatory: true
Expand All @@ -86,17 +88,18 @@ tags: { # amp-ad-metadata (json)
tag_name: "SCRIPT"
spec_name: "amp-ad-metadata .json script"
mandatory_parent: "BODY"
attrs: {
name: "type"
mandatory: true
value_casei: "application/json"
}
attrs: {
name: "amp-ad-metadata"
mandatory: true
value: ""
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "type"
mandatory: true
value_casei: "application/json"
}
cdata: {
blacklisted_cdata_regex: {
regex: "<!--"
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-anim/0.1/validator-amp-anim.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-anim
value: "amp-anim"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
Expand Up @@ -32,6 +32,7 @@ tags: { # amp-apester-media
value: "amp-apester-media"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
Expand Up @@ -31,6 +31,7 @@ tags: { # <script custom-element="amp-sticky-ad">
value: "amp-app-banner"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -53,15 +54,17 @@ tags: { # <amp-app-banner>
tag_name: "AMP-APP-BANNER"
spec_name: "amp-app-banner"
mandatory_parent: "BODY"

requires: "amp-app-banner data source"
also_requires_tag: "amp-app-banner extension .js script"
# The "amp-app-banner button[open-button]" tag is in
# validator-main.protoascii and in turn has an "AMP-APP-BANNER"
# mandatory_parent.
also_requires_tag: "amp-app-banner button[open-button]"
attrs: {
name: "id"
mandatory: true
}
attr_lists: "extended-amp-global"
attrs: { name: "id" mandatory: true }
unique: true
spec_url: "https://www.ampproject.org/docs/reference/extended/amp-add-banner.html"
amp_layout: {
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-audio/0.1/validator-amp-audio.protoascii
Expand Up @@ -31,6 +31,7 @@ tags: { # amp-audio
value: "amp-audio"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -50,7 +51,6 @@ tags: { # amp-audio
}
attr_lists: { # amp-audio attributes that are common to both AMP and A4A format.
name: "amp-audio-common"

attrs: { name: "controls" }
attrs: { name: "loop" value: "" }
attrs: { name: "muted" value: "" }
Expand Down
7 changes: 5 additions & 2 deletions extensions/amp-auto-ads/0.1/validator-amp-auto-ads.protoascii
Expand Up @@ -31,6 +31,7 @@ tags: { # amp-auto-ads
value: "amp-auto-ads"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -54,8 +55,10 @@ tags: { # <amp-auto-ads>
disallowed_ancestor: "AMP-AUTO-ADS"
disallowed_ancestor: "AMP-SIDEBAR"
also_requires_tag: "amp-auto-ads extension .js script"
attrs: { name: "type" mandatory: true }
attrs: {
name: "type"
mandatory: true
}
attr_lists: "extended-amp-global"

spec_url: "https://github.com/ampproject/amphtml/issues/6196"
}
2 changes: 2 additions & 0 deletions extensions/amp-bind/0.1/validator-amp-bind.protoascii
Expand Up @@ -31,6 +31,7 @@ tags: { # amp-bind
value: "amp-bind"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down Expand Up @@ -65,6 +66,7 @@ tags: { # <amp-state> (json)
tag_name: "SCRIPT"
spec_name: "amp-bind extension .json script"
mandatory_parent: "AMP-STATE"
attrs: { name: "nonce" }
attrs: {
name: "type"
mandatory: true
Expand Down
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-brid-player
value: "amp-brid-player"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-brightcove
value: "amp-brightcove"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -56,7 +57,10 @@ tags: { # <amp-brightcove>
tag_name: "AMP-BRIGHTCOVE"
disallowed_ancestor: "AMP-SIDEBAR"
also_requires_tag: "amp-brightcove extension .js script"
attrs: { name: "data-account" mandatory: true }
attrs: {
name: "data-account"
mandatory: true
}
# If data-embed is missing, the default value is "default".
attrs: { name: "data-embed" }
# If data-player is missing, the default value is "default".
Expand Down
31 changes: 25 additions & 6 deletions extensions/amp-carousel/0.1/validator-amp-carousel.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-carousel
value: "amp-carousel"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -56,13 +57,31 @@ tags: { # <amp-carousel>
tag_name: "AMP-CAROUSEL"
disallowed_ancestor: "AMP-SIDEBAR"
also_requires_tag: "amp-carousel extension .js script"
attrs: { name: "arrows" value: "" }
attrs: { name: "autoplay" value: "" }
attrs: {
name: "arrows"
value: ""
}
attrs: {
name: "autoplay"
value: ""
}
attrs: { name: "controls" }
attrs: { name: "delay" value_regex: "[0-9]+" }
attrs: { name: "dots" value: "" }
attrs: { name: "loop" value: "" }
attrs: { name: "type" value_regex: "slides|carousel" }
attrs: {
name: "delay"
value_regex: "[0-9]+"
}
attrs: {
name: "dots"
value: ""
}
attrs: {
name: "loop"
value: ""
}
attrs: {
name: "type"
value_regex: "slides|carousel"
}
attr_lists: "extended-amp-global"
spec_url: "https://www.ampproject.org/docs/reference/extended/amp-carousel.html"
amp_layout: {
Expand Down
Expand Up @@ -32,6 +32,7 @@ tags: { # amp-dailymotion
value: "amp-dailymotion"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -55,13 +56,34 @@ tags: { # <amp-dailymotion>
tag_name: "AMP-DAILYMOTION"
disallowed_ancestor: "AMP-SIDEBAR"
also_requires_tag: "amp-dailymotion extension .js script"
attrs: { name: "data-endscreen-enable" value_regex: "true|false" }
attrs: { name: "data-info" value_regex: "true|false" }
attrs: { name: "data-mute" value_regex: "true|false" }
attrs: { name: "data-sharing-enable" value_regex: "true|false" }
attrs: { name: "data-start" value_regex: "[0-9]+" }
attrs: { name: "data-ui-highlight" value_regex_casei: "([0-9a-f]{3}){1,2}" }
attrs: { name: "data-ui-logo" value_regex: "true|false" }
attrs: {
name: "data-endscreen-enable"
value_regex: "true|false"
}
attrs: {
name: "data-info"
value_regex: "true|false"
}
attrs: {
name: "data-mute"
value_regex: "true|false"
}
attrs: {
name: "data-sharing-enable"
value_regex: "true|false"
}
attrs: {
name: "data-start"
value_regex: "[0-9]+"
}
attrs: {
name: "data-ui-highlight"
value_regex_casei: "([0-9a-f]{3}){1,2}"
}
attrs: {
name: "data-ui-logo"
value_regex: "true|false"
}
attrs: {
name: "data-videoid"
mandatory: true
Expand Down
Expand Up @@ -31,6 +31,7 @@ tags: { # amp-dynamic-css-classes
value: "amp-dynamic-css-classes"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-experiment
value: "amp-experiment"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -55,6 +56,7 @@ tags: { # amp-experiment (json)
tag_name: "SCRIPT"
spec_name: "amp-experiment extension .json script"
mandatory_parent: "AMP-EXPERIMENT"
attrs: { name: "nonce" }
attrs: {
name: "type"
mandatory: true
Expand Down
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-facebook
value: "amp-facebook"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand All @@ -57,7 +58,10 @@ tags: { # <amp-facebook>
disallowed_ancestor: "AMP-SIDEBAR"
also_requires_tag: "amp-facebook extension .js script"
# data-* is generally allowed, but it's not generally mandatory.
attrs: { name: "data-href" mandatory: true }
attrs: {
name: "data-href"
mandatory: true
}
attr_lists: "extended-amp-global"
spec_url: "https://www.ampproject.org/docs/reference/extended/amp-facebook.html"
amp_layout: {
Expand Down
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-fit-text
value: "amp-fit-text"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-font/0.1/validator-amp-font.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-font
value: "amp-font"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-form/0.1/validator-amp-form.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-form
value: "amp-form"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
Expand Up @@ -32,6 +32,7 @@ tags: { # <script custom-element="amp-fx-flying-carpet">
value: "amp-fx-flying-carpet"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-gfycat/0.1/validator-amp-gfycat.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-gfycat
value: "amp-gfycat"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-hulu/0.1/validator-amp-hulu.protoascii
Expand Up @@ -33,6 +33,7 @@ tags: { # amp-hulu
value: "amp-hulu"
dispatch_key: true
}
attrs: { name: "nonce" }
attrs: {
name: "src"
mandatory: true
Expand Down

0 comments on commit d17e7e2

Please sign in to comment.