Texturize: Only convert &
to &
within text nodes.
Previously, `&` would be converted everywhere, which caused problems when it was converted within a `<script>`, for example. `convert_chars()` is now removed from the `the_content` filter, as it was doing the same job as `wptexturize()`. KSES correctly handles converting `&` within HTML attributes, so there's no need for `wptexturize()` and `convert_chars()` to do the same job. Fixes #34698. git-svn-id: https://develop.svn.wordpress.org/trunk@35709 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c7e05dafbe
commit
274bb41c04
@ -131,7 +131,6 @@ add_filter( 'the_title', 'trim' );
|
|||||||
|
|
||||||
add_filter( 'the_content', 'wptexturize' );
|
add_filter( 'the_content', 'wptexturize' );
|
||||||
add_filter( 'the_content', 'convert_smilies' );
|
add_filter( 'the_content', 'convert_smilies' );
|
||||||
add_filter( 'the_content', 'convert_chars' );
|
|
||||||
add_filter( 'the_content', 'wpautop' );
|
add_filter( 'the_content', 'wpautop' );
|
||||||
add_filter( 'the_content', 'shortcode_unautop' );
|
add_filter( 'the_content', 'shortcode_unautop' );
|
||||||
add_filter( 'the_content', 'prepend_attachment' );
|
add_filter( 'the_content', 'prepend_attachment' );
|
||||||
|
@ -276,12 +276,13 @@ function wptexturize( $text, $reset = false ) {
|
|||||||
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
|
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
|
||||||
$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl );
|
$curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace each & with & unless it already looks like an entity.
|
||||||
|
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$text = implode( '', $textarr );
|
|
||||||
|
|
||||||
// Replace each & with & unless it already looks like an entity.
|
return implode( '', $textarr );
|
||||||
return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1267,12 +1267,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||||||
'[caption – is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
|
'[caption – is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]',
|
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]',
|
||||||
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]',
|
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a>]',
|
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]',
|
||||||
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a>]',
|
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'[gallery ...]',
|
'[gallery ...]',
|
||||||
|
Loading…
Reference in New Issue
Block a user