Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator Roll-up #3885

Merged
merged 7 commits into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions extensions/amp-ad/0.1/validator-amp-ad.protoascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#
# Copyright 2016 The AMP HTML Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the license.

# In the AMP Runtime, amp-ad and amp-embed are implemented in the samei
# extension, so we include them both here.

tags: { # amp-ad
tag_name: "SCRIPT"
spec_name: "amp-ad extension .js script"
mandatory_parent: "HEAD"
attrs: {
name: "async"
mandatory: true
value: ""
}
attrs: {
name: "custom-element"
mandatory: true
value: "amp-ad"
dispatch_key: true
}
attrs: {
name: "src"
mandatory: true
value_regex: "https://cdn\\.ampproject\\.org/v0/amp-ad-(latest|0\\.1).js"
}
attrs: {
name: "type"
value: "text/javascript"
}
cdata: {
blacklisted_cdata_regex: {
regex: "."
error_message: "contents"
}
}
spec_url: "https://www.ampproject.org/docs/reference/extended/amp-ad.html"
}
tags: { # <amp-ad>
tag_name: "AMP-AD"
# Typically we'd require the extension j/s, but for historical reasons
# many pages don't have it, so it ends up late loaded.
# TODO(gregable): Make the lack of the extension a deprecation warning.
# also_requires_tag: "amp-ad extension .js script"
disallowed_ancestor: "AMP-SIDEBAR"
attrs: { name: "alt" }
attrs: { name: "json" }
attrs: {
name: "src"
value_url: {
allowed_protocol: "https"
allow_relative: true # Will be set to false at a future date.
}
}
attrs: { name: "type" mandatory: true }
attr_lists: "extended-amp-global"
spec_url: "https://www.ampproject.org/docs/reference/amp-ad.html"
amp_layout: {
supported_layouts: FILL
supported_layouts: FIXED
supported_layouts: FIXED_HEIGHT
supported_layouts: FLEX_ITEM
supported_layouts: NODISPLAY
supported_layouts: RESPONSIVE
}
}
tags: { # <amp-embed>
tag_name: "AMP-EMBED"
# Typically we'd require the extension j/s, but for historical reasons
# many pages don't have it, so it ends up late loaded.
# TODO(gregable): Make the lack of the extension a deprecation warning.
# also_requires_tag: "amp-ad extension .js script"
disallowed_ancestor: "AMP-SIDEBAR"
attrs: { name: "alt" }
attrs: { name: "json" }
attrs: {
name: "src"
value_url: {
allowed_protocol: "https"
allow_relative: true # Will be set to false at a future date.
}
}
attrs: { name: "type" mandatory: true }
attr_lists: "extended-amp-global"
spec_url: "https://www.ampproject.org/docs/reference/amp-embed.html"
amp_layout: {
supported_layouts: FILL
supported_layouts: FIXED
supported_layouts: FIXED_HEIGHT
supported_layouts: FLEX_ITEM
supported_layouts: NODISPLAY
supported_layouts: RESPONSIVE
}
}
50 changes: 50 additions & 0 deletions extensions/amp-form/0.1/validator-amp-form.protoascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright 2016 The AMP HTML Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the license.
#
tags: { # amp-form
# Accepted form elements can be found in validator-main.protoascii
# under section "4.10 Forms"
tag_name: "SCRIPT"
spec_name: "amp-form extension .js script"
mandatory_parent: "HEAD"
attrs: {
name: "async"
mandatory: true
value: ""
}
attrs: {
name: "custom-element"
mandatory: true
value: "amp-form"
dispatch_key: true
}
attrs: {
name: "src"
mandatory: true
value_regex: "https://cdn\\.ampproject\\.org/v0/amp-form-(latest|0\\.1).js"
}
attrs: {
name: "type"
value: "text/javascript"
}
cdata: {
blacklisted_cdata_regex: {
regex: "."
error_message: "contents"
}
}
# TODO: update with ampproject.org url when available
spec_url: "https://github.com/ampproject/amphtml/blob/master/extensions/amp-form/amp-form.md"
}
3 changes: 3 additions & 0 deletions extensions/amp-mustache/0.1/test/validator-amp-mustache.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<p title="{{{notallowed}}}"></p>
<p title="{{&notallowed}}"></p>
<p title="{{>notallowed}}"></p>
<p data-title="{{{notallowed}}}"></p>
<p data-title="{{&notallowed}}"></p>
<p data-title="{{>notallowed}}"></p>

<!-- now with some whitespace inside the mustache tags -->
<{{ not-actually-parsed-as-an-html-tag-so-allowed }}>
Expand Down
41 changes: 22 additions & 19 deletions extensions/amp-mustache/0.1/test/validator-amp-mustache.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ amp-mustache/0.1/test/validator-amp-mustache.html:45:2 Mustache template syntax
amp-mustache/0.1/test/validator-amp-mustache.html:46:2 The attribute 'title' in tag 'p' is set to '{{{notallowed}}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:47:2 The attribute 'title' in tag 'p' is set to '{{&notallowed}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:48:2 The attribute 'title' in tag 'p' is set to '{{>notallowed}}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:53:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:54:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:55:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:56:2 Mustache template syntax in attribute name 'data-{{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:57:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:49:2 The attribute 'data-title' in tag 'p' is set to '{{{notallowed}}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:50:2 The attribute 'data-title' in tag 'p' is set to '{{&notallowed}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:51:2 The attribute 'data-title' in tag 'p' is set to '{{>notallowed}}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:56:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:57:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:58:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:59:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:59:2 Mustache template syntax in attribute name 'data-{{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:60:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:61:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:62:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:63:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:64:2 The attribute 'title' in tag 'p' is set to '{{{ notallowed }}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:65:2 The attribute 'title' in tag 'p' is set to '{{ &notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:66:2 The attribute 'title' in tag 'p' is set to '{{ >notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:67:2 The attribute 'title' in tag 'p' is set to '{{& notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:68:2 The attribute 'title' in tag 'p' is set to '{{> notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:69:2 The attribute 'title' in tag 'p' is set to '{{ & notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:70:2 The attribute 'title' in tag 'p' is set to '{{ > notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:95:4 The tag 'template' may not appear as a descendant of tag 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:107:0 The attribute 'autoplay' in tag 'amp-audio' is set to the invalid value '{{invalid}}'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:121:7 The tag 'amp-audio extension .js script' is missing or incorrect, but required by 'amp-audio'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:121:7 The tag 'amp-mustache extension .js script' is missing or incorrect, but required by 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_TAG_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:62:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:63:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:64:2 Mustache template syntax in attribute name 'data-{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:65:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:66:2 Mustache template syntax in attribute name '{{' in tag 'p'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:67:2 The attribute 'title' in tag 'p' is set to '{{{ notallowed }}}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:68:2 The attribute 'title' in tag 'p' is set to '{{ &notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:69:2 The attribute 'title' in tag 'p' is set to '{{ >notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:70:2 The attribute 'title' in tag 'p' is set to '{{& notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:71:2 The attribute 'title' in tag 'p' is set to '{{> notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:72:2 The attribute 'title' in tag 'p' is set to '{{ & notallowed }}', which contains unescaped Mustache template syntax. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:73:2 The attribute 'title' in tag 'p' is set to '{{ > notallowed }}', which contains a Mustache template partial. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:98:4 The tag 'template' may not appear as a descendant of tag 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_HTML_TEMPLATE_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:110:0 The attribute 'autoplay' in tag 'amp-audio' is set to the invalid value '{{invalid}}'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:124:7 The tag 'amp-audio extension .js script' is missing or incorrect, but required by 'amp-audio'. (see https://www.ampproject.org/docs/reference/extended/amp-audio.html) [AMP_TAG_PROBLEM]
amp-mustache/0.1/test/validator-amp-mustache.html:124:7 The tag 'amp-mustache extension .js script' is missing or incorrect, but required by 'template'. (see https://www.ampproject.org/docs/reference/extended/amp-mustache.html) [AMP_TAG_PROBLEM]
12 changes: 9 additions & 3 deletions validator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var url = require('url');
var util = require('util');
var vm = require('vm');

/**
* Determines if str begins with prefix.
* @param {!string} str
* @param {!string} prefix
* @returns {!boolean}
*/
function hasPrefix(str, prefix) {
return str.indexOf(prefix) == 0;
}
Expand Down Expand Up @@ -263,7 +269,7 @@ Validator.prototype.validateString =
result.errors.push(error);
}
return result;
}
};

/**
* A global static map used by the getInstance function to avoid loading
Expand Down Expand Up @@ -320,7 +326,7 @@ function logValidationResult(filename, validationResult, color) {
msg += (error.severity === 'ERROR' ? colors.red : colors.magenta)(
error.message);
} else {
msg += error.message
msg += error.message;
}
if (error.specUrl) {
msg += ' (see ' + error.specUrl + ')';
Expand Down Expand Up @@ -393,7 +399,7 @@ function main() {
}
}
if (program.format === 'json') {
console.log(JSON.stringify(jsonOut))
console.log(JSON.stringify(jsonOut));
}
})
.catch(function(error) {
Expand Down
Loading