-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Labels
Milestone
Description
Bug Description
The following logic in \AMP_Tag_And_Attribute_Sanitizer::sanitize_disallowed_attribute_values_in_node() is lacking:
amp-wp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php
Lines 1247 to 1251 in 2549ca3
| // Check the context to see if we are currently within a template tag. | |
| // If this is the case and the attribute value contains a template placeholder, we skip sanitization. | |
| if ( ! empty( $this->open_elements['template'] ) && preg_match( '/{{[^}]+?}}/', $attr_node->nodeValue ) ) { | |
| continue; | |
| } |
Namely, a Mustache template can also be in a script tag that has type=text/plain and template=amp-mustache (see docs).
So anywhere that we are checking for a template tag we should also check for script with the required attributes. For example, in the form sanitizer:
| $templates = $form->getElementsByTagName( 'template' ); |
Expected Behaviour
Mustache templates in template tags are treated the same as templates in script tags.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
Reactions are currently unavailable