-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #892 from Automattic/fix/script-tags-output-cdata
Address an issue where <script> tags aren't stripped.
- Loading branch information
Showing
6 changed files
with
34 additions
and
1,444 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
Follow the steps below to generate a new version of the allowed tags class: | ||
- Download a copy of the latet AMPHTML repository from github: | ||
git clone [email protected]:ampproject/amphtml.git | ||
- Copy this file into the repo's validator subdirectory: | ||
|
@@ -99,7 +99,7 @@ def GenValidatorProtoascii(out_dir): | |
|
||
|
||
def GeneratePHP(out_dir): | ||
"""Calls validator_gen_md to generate validator-generated.md. | ||
"""Generates PHP for WordPress AMP plugin to consume. | ||
Args: | ||
out_dir: directory name of the output directory. Must not have slashes, | ||
|
@@ -223,15 +223,15 @@ def GenerateAttributesPHP(out, attributes, indent_level = 4): | |
indent = '' | ||
for i in range(0,indent_level): | ||
indent += '\t' | ||
|
||
sorted_attributes = sorted(attributes.items()) | ||
for (attribute, values) in collections.OrderedDict(sorted_attributes).iteritems(): | ||
logging.info('generating php for attribute: %s...' % attribute.lower()) | ||
out.append('%s\'%s\' => array(' % (indent, attribute.lower())) | ||
GeneratePropertiesPHP(out, values) | ||
out.append('%s),' % indent) | ||
logging.info('...done with: %s' % attribute.lower()) | ||
|
||
out.append('') | ||
logging.info('... done') | ||
|
||
|
@@ -336,7 +336,6 @@ def ParseRules(out_dir): | |
# are checked by CheckPrereqs. | ||
from google.protobuf import text_format | ||
from amp_wp import validator_pb2 | ||
import validator_gen_md | ||
|
||
allowed_tags = {} | ||
attr_lists = {} | ||
|
@@ -399,7 +398,14 @@ def ParseRules(out_dir): | |
else: | ||
tag_list = allowed_tags[UnicodeEscape(tag_spec.tag_name)] | ||
# AddTag(allowed_tags, tag_spec, attr_lists) | ||
tag_list.append(GetTagSpec(tag_spec, attr_lists)) | ||
|
||
gotten_tag_spec = GetTagSpec(tag_spec, attr_lists) | ||
|
||
# Temporarily skip extension SCRIPT elemeents which appear in the HEAD. | ||
if 'SCRIPT' == tag_spec.tag_name and gotten_tag_spec['tag_spec'].get( '_is_extension_spec', False ): | ||
continue | ||
|
||
tag_list.append(gotten_tag_spec) | ||
allowed_tags[UnicodeEscape(tag_spec.tag_name)] = tag_list | ||
|
||
logging.info('... done') | ||
|
@@ -449,6 +455,9 @@ def GetTagRules(tag_spec): | |
html_format_list.append('amp4ads') | ||
tag_rules['html_format'] = {'html_format': html_format_list} | ||
|
||
if tag_spec.HasField('extension_spec'): | ||
tag_rules['_is_extension_spec'] = True; | ||
|
||
if tag_spec.HasField('mandatory'): | ||
tag_rules['mandatory'] = tag_spec.mandatory | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.