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:
Henri Yandell 2007-10-26 06:08:54 +00:00
parent ed7e9b4349
commit c22d9d59e5
2 changed files with 6 additions and 0 deletions

View File

@ -233,6 +233,10 @@ public class StringEscapeUtils {
out.write('\\');
out.write('\\');
break;
case '/':
out.write('\\');
out.write('/');
break;
default :
out.write(ch);
break;

View File

@ -184,6 +184,8 @@ public class StringEscapeUtilsTest extends TestCase {
}
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>';"));
}