Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created November 4, 2019 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/e6762e351c40d2a480cbf5d63da9fa5c to your computer and use it in GitHub Desktop.
Save westonruter/e6762e351c40d2a480cbf5d63da9fa5c to your computer and use it in GitHub Desktop.
diff --git a/includes/sanitizers/class-amp-base-sanitizer.php b/includes/sanitizers/class-amp-base-sanitizer.php
index 2482db29..e2171079 100644
--- a/includes/sanitizers/class-amp-base-sanitizer.php
+++ b/includes/sanitizers/class-amp-base-sanitizer.php
@@ -486,8 +486,12 @@ abstract class AMP_Base_Sanitizer {
}
$should_remove = $this->should_sanitize_validation_error( $validation_error, compact( 'node' ) );
if ( $should_remove ) {
- $element->removeAttributeNode( $node );
- $this->clean_up_after_attribute_removal( $element, $node, $validation_error );
+ try {
+ $element->removeAttributeNode( $node );
+ $this->clean_up_after_attribute_removal( $element, $node, $validation_error );
+ } catch ( Exception $e ) {
+ error_log( sprintf( 'Failed to remove attribute %s from element %s', $node->nodeName, $element->nodeName ) );
+ }
}
return $should_remove;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment