Update convert_chars():
- Stop trying to remove `<title>` and `<category>` meta tags. They have not been used for many many years. - Replacement of `<br>` with `<br />` and `<hr>` with `<hr />` is not needed for HTML 5.0. Also, these tags are formatted like that by the visual editor. - Replace invalid HTML entities that might be pasted in the Text editor on save instead of on display. Fixes #32335. Built from https://develop.svn.wordpress.org/trunk@32896 git-svn-id: http://core.svn.wordpress.org/trunk@32867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
095dfe5386
commit
b9a4fefb08
|
@ -87,6 +87,7 @@ add_filter( 'post_mime_type', 'sanitize_mime_type' );
|
||||||
|
|
||||||
// Places to balance tags on input
|
// Places to balance tags on input
|
||||||
foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
|
foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
|
||||||
|
add_filter( $filter, 'convert_invalid_entities' );
|
||||||
add_filter( $filter, 'balanceTags', 50 );
|
add_filter( $filter, 'balanceTags', 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1503,11 +1503,7 @@ function sanitize_html_class( $class, $fallback = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a number of characters from a string.
|
* Converts lone & characters into `&` (a.k.a. `&`)
|
||||||
*
|
|
||||||
* Metadata tags `<title>` and `<category>` are removed, `<br>` and `<hr>` are
|
|
||||||
* converted into correct XHTML and Unicode characters are converted to the
|
|
||||||
* valid range.
|
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
*
|
*
|
||||||
|
@ -1516,10 +1512,26 @@ function sanitize_html_class( $class, $fallback = '' ) {
|
||||||
* @return string Converted string.
|
* @return string Converted string.
|
||||||
*/
|
*/
|
||||||
function convert_chars( $content, $deprecated = '' ) {
|
function convert_chars( $content, $deprecated = '' ) {
|
||||||
if ( !empty( $deprecated ) )
|
if ( ! empty( $deprecated ) ) {
|
||||||
_deprecated_argument( __FUNCTION__, '0.71' );
|
_deprecated_argument( __FUNCTION__, '0.71' );
|
||||||
|
}
|
||||||
|
|
||||||
// Translation of invalid Unicode references range to valid range
|
if ( strpos( $content, '&' ) !== false ) {
|
||||||
|
$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts invalid Unicode references range to valid range.
|
||||||
|
*
|
||||||
|
* @since 4.3
|
||||||
|
*
|
||||||
|
* @param string $content String with entities that need converting.
|
||||||
|
* @return string Converted string.
|
||||||
|
*/
|
||||||
|
function convert_invalid_entities( $content ) {
|
||||||
$wp_htmltranswinuni = array(
|
$wp_htmltranswinuni = array(
|
||||||
'€' => '€', // the Euro sign
|
'€' => '€', // the Euro sign
|
||||||
'' => '',
|
'' => '',
|
||||||
|
@ -1555,19 +1567,9 @@ function convert_chars( $content, $deprecated = '' ) {
|
||||||
'Ÿ' => 'Ÿ'
|
'Ÿ' => 'Ÿ'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove metadata tags
|
if ( strpos( $content, '' ) !== false ) {
|
||||||
$content = preg_replace('/<title>(.+?)<\/title>/','',$content);
|
$content = strtr( $content, $wp_htmltranswinuni );
|
||||||
$content = preg_replace('/<category>(.+?)<\/category>/','',$content);
|
}
|
||||||
|
|
||||||
// Converts lone & characters into & (a.k.a. &)
|
|
||||||
$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);
|
|
||||||
|
|
||||||
// Fix Word pasting
|
|
||||||
$content = strtr($content, $wp_htmltranswinuni);
|
|
||||||
|
|
||||||
// Just a little XHTML help
|
|
||||||
$content = str_replace('<br>', '<br />', $content);
|
|
||||||
$content = str_replace('<hr>', '<hr />', $content);
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32895';
|
$wp_version = '4.3-alpha-32896';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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