From 878e023274622a4683a7338478af1c1958f070a9 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 1 Mar 2018 13:53:40 -0600 Subject: [PATCH] Issue #864: Convert 'data-amp-layout' to 'layout.' In the image preprocessor, Convert a 'data-amp-layout' attribute to 'layout.' As Weston mentioned, this won't change the styling on non-AMP pages, As the preprocessor won't modify them. --- .../sanitizers/class-amp-img-sanitizer.php | 4 +++ tests/test-amp-img-sanitizer.php | 29 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/includes/sanitizers/class-amp-img-sanitizer.php b/includes/sanitizers/class-amp-img-sanitizer.php index 4f4169b729d..45d4e3c9b3a 100644 --- a/includes/sanitizers/class-amp-img-sanitizer.php +++ b/includes/sanitizers/class-amp-img-sanitizer.php @@ -129,6 +129,10 @@ private function filter_attributes( $attributes ) { $out[ $name ] = $this->sanitize_dimension( $value, $name ); break; + case 'data-amp-layout': + $out['layout'] = $value; + break; + default: break; } diff --git a/tests/test-amp-img-sanitizer.php b/tests/test-amp-img-sanitizer.php index 557b9faa675..52889dd1097 100644 --- a/tests/test-amp-img-sanitizer.php +++ b/tests/test-amp-img-sanitizer.php @@ -12,42 +12,47 @@ public function setUp() { public function get_data() { return array( - 'no_images' => array( + 'no_images' => array( '

Lorem Ipsum Demet Delorit.

', '

Lorem Ipsum Demet Delorit.

', ), - 'image_without_src' => array( + 'image_without_src' => array( '

', '

', ), - 'image_with_empty_src' => array( + 'image_with_empty_src' => array( '

', '

', ), - 'image_with_self_closing_tag' => array( + 'image_with_layout' => array( + '', + '', + ), + + 'image_with_self_closing_tag' => array( 'Placeholder!', '', ), - 'image_with_no_end_tag' => array( + 'image_with_no_end_tag' => array( 'Placeholder!', '', ), - 'image_with_end_tag' => array( + 'image_with_end_tag' => array( 'Placeholder!', '', ), - 'image_with_on_attribute' => array( + 'image_with_on_attribute' => array( '', '', ), - 'image_with_blacklisted_attribute' => array( + 'image_with_blacklisted_attribute' => array( '', '', ), @@ -62,17 +67,17 @@ public function get_data() { '', ), - 'gif_image_conversion' => array( + 'gif_image_conversion' => array( 'Placeholder!', '', ), - 'gif_image_url_with_querystring' => array( + 'gif_image_url_with_querystring' => array( 'Placeholder!', '', ), - 'multiple_same_image' => array( + 'multiple_same_image' => array( ' @@ -81,7 +86,7 @@ public function get_data() { '', ), - 'multiple_different_images' => array( + 'multiple_different_images' => array( '