Skip to content

Commit f5e925f

Browse files
committed
Hardening: Add escaping to the language attributes used on html elements.
Merges [42259] to the 3.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/3.7@42313 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a826ee2 commit f5e925f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/wp-includes/general-template.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,12 +1927,14 @@ function language_attributes($doctype = 'html') {
19271927
if ( function_exists( 'is_rtl' ) && is_rtl() )
19281928
$attributes[] = 'dir="rtl"';
19291929

1930-
if ( $lang = get_bloginfo('language') ) {
1931-
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
1932-
$attributes[] = "lang=\"$lang\"";
1930+
if ( $lang = get_bloginfo( 'language' ) ) {
1931+
if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
1932+
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
1933+
}
19331934

1934-
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1935-
$attributes[] = "xml:lang=\"$lang\"";
1935+
if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
1936+
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
1937+
}
19361938
}
19371939

19381940
$output = implode(' ', $attributes);

0 commit comments

Comments
 (0)