Dan Wallach created LANG-1180:
---------------------------------
Summary: StringEscapeUtils.escapeEcmaScript incorrectly handles
single-quotes
Key: LANG-1180
URL: https://issues.apache.org/jira/browse/LANG-1180
Project: Commons Lang
Issue Type: Bug
Affects Versions: 3.4
Reporter: Dan Wallach
Priority: Minor
The following code illustrates the problem:
public void testEscapes() {
String ecmaSingleEscape = StringEscapeUtils.escapeEcmaScript("X'Y");
String ecmaDoubleEscape = StringEscapeUtils.escapeEcmaScript("X\"Y");
assertEquals("X\\\"Y", ecmaDoubleEscape); // works correctly
assertEquals("X'Y", ecmaSingleEscape); // incorrectly inserts a
backslash
}
According to json.org, single-quote is not a valid character for being
backslash-escaped in a string. The only valid backslash escapes are:
\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)