Skip to content

Commit feababc

Browse files
committed
Prevent case where validation error can be raised on already-removed node
This prevents a validation error from having no source stack
1 parent 905ae4a commit feababc

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,9 @@ static function ( $validation_error ) {
535535
} else {
536536
// Otherwise, we have a rare condition where multiple tag specs fail for different reasons.
537537
foreach ( $validation_errors as $validation_error ) {
538-
$this->remove_invalid_child(
539-
$node,
540-
$validation_error
541-
);
538+
if ( true === $this->remove_invalid_child( $node, $validation_error ) ) {
539+
break; // Once removed, ignore remaining errors.
540+
}
542541
}
543542
}
544543
}

tests/php/test-tag-and-attribute-sanitizer.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ public function get_body_data() {
9696
'spec_name' => 'noscript enclosure for boilerplate',
9797
'required_parent_name' => 'head',
9898
],
99-
[
100-
'code' => AMP_Tag_And_Attribute_Sanitizer::DISALLOWED_TAG_ANCESTOR,
101-
'disallowed_ancestor' => 'noscript',
102-
'spec_name' => 'noscript',
103-
],
10499
],
105100
],
106101

0 commit comments

Comments
 (0)