Skip to content

Commit

Permalink
Prevent case where validation error can be raised on already-removed …
Browse files Browse the repository at this point in the history
…node

This prevents a validation error from having no source stack
  • Loading branch information
westonruter committed Mar 21, 2020
1 parent 905ae4a commit feababc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 3 additions & 4 deletions includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,9 @@ static function ( $validation_error ) {
} else {
// Otherwise, we have a rare condition where multiple tag specs fail for different reasons.
foreach ( $validation_errors as $validation_error ) {
$this->remove_invalid_child(
$node,
$validation_error
);
if ( true === $this->remove_invalid_child( $node, $validation_error ) ) {
break; // Once removed, ignore remaining errors.
}
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions tests/php/test-tag-and-attribute-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public function get_body_data() {
'spec_name' => 'noscript enclosure for boilerplate',
'required_parent_name' => 'head',
],
[
'code' => AMP_Tag_And_Attribute_Sanitizer::DISALLOWED_TAG_ANCESTOR,
'disallowed_ancestor' => 'noscript',
'spec_name' => 'noscript',
],
],
],

Expand Down

0 comments on commit feababc

Please sign in to comment.