diff --git a/includes/sanitizers/class-amp-img-sanitizer.php b/includes/sanitizers/class-amp-img-sanitizer.php index 86fe45e2770..e4a99512dea 100644 --- a/includes/sanitizers/class-amp-img-sanitizer.php +++ b/includes/sanitizers/class-amp-img-sanitizer.php @@ -73,7 +73,7 @@ public function sanitize() { continue; } - if ( ! $node->hasAttribute( 'src' ) || '' === $node->getAttribute( 'src' ) ) { + if ( ! $node->hasAttribute( 'src' ) || '' === trim( $node->getAttribute( 'src' ) ) ) { $this->remove_invalid_child( $node ); continue; } diff --git a/tests/test-amp-img-sanitizer.php b/tests/test-amp-img-sanitizer.php index a6a400264a1..c9c02a90633 100644 --- a/tests/test-amp-img-sanitizer.php +++ b/tests/test-amp-img-sanitizer.php @@ -27,6 +27,11 @@ public function get_data() { '
', ), + 'image_with_spaces_only_src' => array( + '', + '', + ), + 'image_with_empty_width_and_height' => array( '', '