From 447d25f090b553f263f612da4bdc23132b8d8eb9 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Thu, 23 Jul 2020 00:42:48 +0000 Subject: [PATCH] Media: Add "loading" as an allowed kses image attribute With loading="lazy" being added to all images in [47554], let's ensure that it passes kses attributes too. Fixes #50731. Props TimothyBlynJacobs, peterwilsoncc, azaozz. git-svn-id: https://develop.svn.wordpress.org/trunk@48572 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/kses.php | 1 + tests/phpunit/tests/kses.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 6a579b8d91..2c0e075ff4 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -230,6 +230,7 @@ if ( ! CUSTOM_TAGS ) { 'border' => true, 'height' => true, 'hspace' => true, + 'loading' => true, 'longdesc' => true, 'vspace' => true, 'src' => true, diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 69870a7033..2c5a6c6706 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -765,6 +765,11 @@ EOF; 'src="mypic.jpg"', 'src="mypic.jpg"', ), + array( + 'img', + 'loading="lazy"', + 'loading="lazy"', + ), array( 'img', 'onerror=alert(1)', @@ -1352,4 +1357,26 @@ EOF; ), ); } + + /** + * Test filtering a standard img tag. + * + * @ticket 50731 + */ + function test_wp_kses_img_tag_standard_attributes() { + $html = array( + '', + ); + + $html = implode( ' ', $html ); + + $this->assertSame( $html, wp_kses_post( $html ) ); + } }