WordPress.org

Make WordPress Core

Opened 5 weeks ago

#47546 new defect (bug)

The language used for the `lang` attribute isn't validated before being used

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: I18N Keywords: needs-patch
Focuses: Cc:

Description

In the admin area, the lang attribute can be populated directly from the WPLANG option or the user's locale meta field. In these cases, no check is performed to ensure that the corresponding language files exist before using the value for the lang attribute.

This can come about if the language files that are used by a user or the site are deleted, or the value is otherwise modified to include an incorrect value.

For example, running wp user meta update admin locale it_IT will result in lang="it_IT" being added to the <html> element, even if the corresponding language files don't exist. This can result in the browser being confused about the language of the page, and can also result in assistive technology handling or pronouncing text incorrectly.

It would be preferable if the existence of the corresponding language files was checked before the lang attribute was output, falling back to en_US as necessary. I'm not sure if it's best to make this change in the get_language_attributes() function, or lower in the determine_locale() or get_bloginfo() functions.

Change History (0)

Note: See TracTickets for help on using tickets.