From a75f27d812b6d1c7b52e8d69b6efd46ae07f6427 Mon Sep 17 00:00:00 2001 From: Alberto Medina Date: Tue, 3 Apr 2018 09:59:00 -0700 Subject: [PATCH] Sanotize img tags when src attribute contains only spaces. Fixes issue #1030 --- includes/sanitizers/class-amp-img-sanitizer.php | 2 +- tests/test-amp-img-sanitizer.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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( '

', '

',