mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-06 18:18:22 +00:00
Applying Scott Bassin's fix and test from LANG-363
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@588534 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed7e9b4349
commit
c22d9d59e5
@ -233,6 +233,10 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape
|
|||||||
out.write('\\');
|
out.write('\\');
|
||||||
out.write('\\');
|
out.write('\\');
|
||||||
break;
|
break;
|
||||||
|
case '/':
|
||||||
|
out.write('\\');
|
||||||
|
out.write('/');
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
out.write(ch);
|
out.write(ch);
|
||||||
break;
|
break;
|
||||||
|
@ -184,6 +184,8 @@ public void testEscapeJavaScript() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeJavaScript("He didn't say, \"stop!\""));
|
assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeJavaScript("He didn't say, \"stop!\""));
|
||||||
|
assertEquals("document.getElementById(\\\"test\\\").value = \\'<script>alert(\\'aaa\\');<\\/script>\\';",
|
||||||
|
StringEscapeUtils.escapeJavaScript("document.getElementById(\"test\").value = '<script>alert('aaa');</script>';"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user