Skip to content

Commit

Permalink
fix: update tests for reverse backslash
Browse files Browse the repository at this point in the history
Co-authored-by: Iris Booker <iris.booker@getbraintree.com>
  • Loading branch information
braintreeps and Iris Booker committed Jul 15, 2024
1 parent 3bbf710 commit a617083
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ describe("sanitizeUrl", () => {
"\rjavascript:alert()",
"\u0000javascript:alert()",
"\u0001javascript:alert()",
"\\j\\av\\a\\s\\cript:alert()",
];

attackVectors.forEach((vector) => {
expect(sanitizeUrl(vector)).toBe(BLANK_URL);
});
});

it("reverses backslashes", () => {
const attack = "\\j\\av\\a\\s\\cript:alert()";

expect(sanitizeUrl(attack)).toBe("/j/av/a/s/cript:alert()");
});

describe("invalid protocols", () => {
describe.each(["javascript", "data", "vbscript"])("%s", (protocol) => {
it(`replaces ${protocol} urls with ${BLANK_URL}`, () => {
Expand Down

0 comments on commit a617083

Please sign in to comment.