Added JS escaping for newline, linefeed, return, tab and backspace. Closes #1

This commit is contained in:
Erik C. Thauvin 2024-02-28 03:29:29 -08:00
parent a0ebfe2566
commit 0d14c27032
2 changed files with 10 additions and 0 deletions

View file

@ -55,6 +55,10 @@ class TestEncode {
t.setAttribute(TestCase.FOO, "'\"\\/");
assertThat(t.getContent()).isEqualTo("\\'\\\"\\\\\\/");
t = TemplateFactory.TXT.get("encodeJs");
t.setAttribute(TestCase.FOO, "This is\f\b a\r\n\ttest");
assertThat(t.getContent()).isEqualTo("This is\\f\\b a\\r\\n\\ttest");
t = TemplateFactory.HTML.get("encodeJs");
t.setAttribute(TestCase.FOO, '"' + TestCase.SAMPLE_TEXT + '"');
assertThat(t.getContent()).as("with unicode")