mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 17:15:16 +01:00
Media: Prevent decoding attribute corrupting JSON data.
Workaround `wp_img_tag_add_decoding_attr()` potentially breaking JavaScript and JSON data by limiting the addition of the decoding attribute to image tags using unescaped double quoted attributes `src` attributes. Props rodricus, TimothyBlynJacobs, joelmadigan, mw108, adamsilverstein, flixos90, desrosj, mukesh27, peterwilsoncc. Merges [54802] to the 6.1 branch. Fixes #56969. Built from https://develop.svn.wordpress.org/branches/6.1@54807 git-svn-id: http://core.svn.wordpress.org/branches/6.1@54359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bc26f71bc1
commit
03af8a6e91
@ -1962,6 +1962,12 @@ function wp_img_tag_add_loading_attr( $image, $context ) {
|
||||
* @return string Converted `img` tag with `decoding` attribute added.
|
||||
*/
|
||||
function wp_img_tag_add_decoding_attr( $image, $context ) {
|
||||
// Only apply the decoding attribute to images that have a src attribute that
|
||||
// starts with a double quote, ensuring escaped JSON is also excluded.
|
||||
if ( false === strpos( $image, ' src="' ) ) {
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the `decoding` attribute value to add to an image. Default `async`.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1.1-alpha-54806';
|
||||
$wp_version = '6.1.1-alpha-54807';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user