Skip to content

Commit

Permalink
fix: decodingURIComponent each sanitize round
Browse files Browse the repository at this point in the history
  • Loading branch information
ibooker committed May 9, 2024
1 parent 15926b6 commit 6c15df9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ describe("sanitizeUrl", () => {
"javascrip%255Ctt:alert()",
"javascrip%25%35Ctt:alert()",
"javascrip%25%35%43tt:alert()",
"javascrip%25%32%35%25%33%35%25%34%33tt:alert()",
];

attackVectors.forEach((vector) => {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function sanitizeUrl(url?: string): string {
.replace(ctrlCharactersRegex, "")
.replace(whitespaceEscapeCharsRegex, "")
.trim();
decodedUrl = decodeURIComponent(decodedUrl);
charsToDecode =
decodedUrl.match(ctrlCharactersRegex) ||
decodedUrl.match(htmlEntitiesRegex) ||
Expand Down

0 comments on commit 6c15df9

Please sign in to comment.