Hardening: Add escaping to the language attributes used on `html` elements.
Merges [42259] to the 4.7 branch. Built from https://develop.svn.wordpress.org/branches/4.7@42273 git-svn-id: http://core.svn.wordpress.org/branches/4.7@42102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
547fd42bfe
commit
e951da4039
|
@ -3118,12 +3118,14 @@ function get_language_attributes( $doctype = 'html' ) {
|
||||||
if ( function_exists( 'is_rtl' ) && is_rtl() )
|
if ( function_exists( 'is_rtl' ) && is_rtl() )
|
||||||
$attributes[] = 'dir="rtl"';
|
$attributes[] = 'dir="rtl"';
|
||||||
|
|
||||||
if ( $lang = get_bloginfo('language') ) {
|
if ( $lang = get_bloginfo( 'language' ) ) {
|
||||||
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
|
if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
|
||||||
$attributes[] = "lang=\"$lang\"";
|
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
|
if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
|
||||||
$attributes[] = "xml:lang=\"$lang\"";
|
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = implode(' ', $attributes);
|
$output = implode(' ', $attributes);
|
||||||
|
|
Loading…
Reference in New Issue