Hardening: Add escaping to the language attributes used on `html` elements.

Merges [42259] to the 3.7 branch.

Built from https://develop.svn.wordpress.org/branches/3.7@42313


git-svn-id: http://core.svn.wordpress.org/branches/3.7@42142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2017-11-29 16:50:09 +00:00
parent 82f8529ad5
commit 149cdb0766
1 changed files with 7 additions and 5 deletions

View File

@ -1927,12 +1927,14 @@ function language_attributes($doctype = 'html') {
if ( function_exists( 'is_rtl' ) && is_rtl() )
$attributes[] = 'dir="rtl"';
if ( $lang = get_bloginfo('language') ) {
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
$attributes[] = "lang=\"$lang\"";
if ( $lang = get_bloginfo( 'language' ) ) {
if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
}
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
$attributes[] = "xml:lang=\"$lang\"";
if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
}
}
$output = implode(' ', $attributes);