...
Any program which invokes local-sensitive methods on untrusted data must explicitly specify the locale to use with these methods.
Noncompliant Code Example
Wiki Markup |
---|
This noncompliant code example uses the locale-sensitive {{String.toUpperCase()}} method to convert an HTML tag to upper case. While the English locale would convert "title" to "TITLE", the Turkish locale will convert "title" to "T?TLE," where '?' is the Latin capital letter 'I' with a dot above the character \[[API 2006|AA. Bibliography#API 06]\]. |
Code Block | ||
---|---|---|
| ||
"title".toUpperCase(); |
Compliant Solution (Explicit Locale)
This compliant solution explicitly sets the locale to English to avoid unexpected results.
...
This rule also applies to the String.equalsIgnoreCase()
method.
Compliant Solution (Default Locale)
This compliant solution sets the default locale to English before proceeding with string operations.
Code Block | ||
---|---|---|
| ||
Locale.setDefault(Locale.ENGLISH); "title".toUpperCase(); |
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
IDS14 IDS09-J | medium | probable | medium | P8 | L2 |
Bibliography
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="26cae153356ea4eb-a7ed93c7-41594949-9762ab7a-058466ba0f5d236a9e6fd8be"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | Class | ]]></ac:plain-text-body></ac:structured-macro> |
...