mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
Since PHP 5.2.3, the htmlspecialchars()
function has an optional $double_encode
parameter, which we can now use. This will save us a few expensive kses/html decoding calls.
Adds unit tests. Props miqrogroove. Fixes #17780. Built from https://develop.svn.wordpress.org/trunk@32850 git-svn-id: http://core.svn.wordpress.org/trunk@32821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f632756f16
commit
d8c93a081d
@ -688,24 +688,7 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
|
|||||||
$quote_style = ENT_NOQUOTES;
|
$quote_style = ENT_NOQUOTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle double encoding ourselves
|
$string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
|
||||||
if ( $double_encode ) {
|
|
||||||
$string = @htmlspecialchars( $string, $quote_style, $charset );
|
|
||||||
} else {
|
|
||||||
// Decode & into &
|
|
||||||
$string = wp_specialchars_decode( $string, $_quote_style );
|
|
||||||
|
|
||||||
// Guarantee every &entity; is valid or re-encode the &
|
|
||||||
$string = wp_kses_normalize_entities( $string );
|
|
||||||
|
|
||||||
// Now re-encode everything except &entity;
|
|
||||||
$string = preg_split( '/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
|
|
||||||
|
|
||||||
for ( $i = 0, $c = count( $string ); $i < $c; $i += 2 ) {
|
|
||||||
$string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset );
|
|
||||||
}
|
|
||||||
$string = implode( '', $string );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Backwards compatibility
|
// Backwards compatibility
|
||||||
if ( 'single' === $_quote_style )
|
if ( 'single' === $_quote_style )
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32849';
|
$wp_version = '4.3-alpha-32850';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user