commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Wallach (JIRA)" <>
Subject [jira] [Created] (LANG-1180) StringEscapeUtils.escapeEcmaScript incorrectly handles single-quotes
Date Wed, 28 Oct 2015 20:01:27 GMT
Dan Wallach created LANG-1180:

             Summary: StringEscapeUtils.escapeEcmaScript incorrectly handles single-quotes
                 Key: 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, single-quote is not a valid character for being backslash-escaped in
a string. The only valid backslash escapes are:

\u four-hex-digits

This message was sent by Atlassian JIRA

View raw message