Texturize: Transform `&` into `&` in tag attributes.
[35709] was overly broad, and stopped transforming `&` characters within tag attributes. So that sites aren't generating invalid HTML, we need to restore this functionality, while continuing to not transform `&` within blocked tags. Fixes #35008 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@36036 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d6bf586de3
commit
59b8f0da7c
|
@ -233,6 +233,10 @@ function wptexturize( $text, $reset = false ) {
|
|||
continue;
|
||||
} else {
|
||||
// This is an HTML element delimiter.
|
||||
|
||||
// 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 );
|
||||
|
||||
_wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags );
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
}
|
||||
|
||||
function test_disable() {
|
||||
$this->assertEquals('<pre>---</pre>', wptexturize('<pre>---</pre>'));
|
||||
$this->assertEquals('<pre><code></code>--</pre>', wptexturize('<pre><code></code>--</pre>'));
|
||||
$this->assertEquals('<pre>---&</pre>', wptexturize('<pre>---&</pre>'));
|
||||
$this->assertEquals('<pre><code></code>--&</pre>', wptexturize('<pre><code></code>--&</pre>'));
|
||||
|
||||
$this->assertEquals( '<code>---</code>', wptexturize( '<code>---</code>' ) );
|
||||
$this->assertEquals( '<kbd>---</kbd>', wptexturize( '<kbd>---</kbd>' ) );
|
||||
$this->assertEquals( '<style>---</style>', wptexturize( '<style>---</style>' ) );
|
||||
$this->assertEquals( '<script>---</script>', wptexturize( '<script>---</script>' ) );
|
||||
$this->assertEquals( '<tt>---</tt>', wptexturize( '<tt>---</tt>' ) );
|
||||
$this->assertEquals( '<code>---&</code>', wptexturize( '<code>---&</code>' ) );
|
||||
$this->assertEquals( '<kbd>---&</kbd>', wptexturize( '<kbd>---&</kbd>' ) );
|
||||
$this->assertEquals( '<style>---&</style>', wptexturize( '<style>---&</style>' ) );
|
||||
$this->assertEquals( '<script>---&</script>', wptexturize( '<script>---&</script>' ) );
|
||||
$this->assertEquals( '<tt>---&</tt>', wptexturize( '<tt>---&</tt>' ) );
|
||||
|
||||
$this->assertEquals('<code>href="baba"</code> “baba”', wptexturize('<code>href="baba"</code> "baba"'));
|
||||
|
||||
|
@ -1268,11 +1268,15 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
),
|
||||
array(
|
||||
'[ 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 & that guy </a> ]',
|
||||
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]',
|
||||
),
|
||||
array(
|
||||
'[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 & that guy </a>]',
|
||||
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]',
|
||||
),
|
||||
array(
|
||||
'& <script>&&</script>',
|
||||
'& <script>&&</script>'
|
||||
),
|
||||
array(
|
||||
'[gallery ...]',
|
||||
|
|
Loading…
Reference in New Issue