Skip to content

Commit

Permalink
Add new test for Alpine.js attribute escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
tschuehly committed Oct 9, 2024
1 parent c3c3e46 commit 23afcaa
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,17 @@ void script4() {
void onMethods() {
codeResolver.givenCode("template.jte", "@param String userName\n\n<span onclick=\"showName('${userName}')\">Click me</span>");

templateEngine.render("template.jte", "'); alert('xss", output);
templateEngine.render("template.jte", "'\n); alert('xss", output);

assertThat(output.toString()).isEqualTo("\n<span onclick=\"showName('\\x27); alert(\\x27xss')\">Click me</span>");
assertThat(output.toString()).isEqualTo("\n<span onclick=\"showName('\\x27\\n); alert(\\x27xss')\">Click me</span>");
}
@Test
void alpineJs() {
codeResolver.givenCode("template.jte", "@param String userName\n\n<span x-init=\"showName('${userName}')\">Click me</span>");

templateEngine.render("template.jte", "\n'); alert('xss", output);

assertThat(output.toString()).isEqualTo("\n<span x-init=\"showName('\\x27\\n); alert(\\x27xss')\">Click me</span>");
}

@Test
Expand Down

0 comments on commit 23afcaa

Please sign in to comment.