Skip to content

Commit 1d0b9fb

Browse files
committed
Prevent ReDoS
1 parent 8528f1b commit 1d0b9fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/vulnerabilities/path-traversal/containsUnsafePathParts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ export function containsUnsafePathParts(filePath: string) {
2020
* See https://url.spec.whatwg.org/#url-parsing
2121
*/
2222
export function containsUnsafePathPartsUrl(filePath: string) {
23-
return /(?:\.(?:\t|\n|\r)*){2}(?:\/|\\)/.test(filePath);
23+
const normalized = filePath.replace(/[\t\n\r]/g, "");
24+
return containsUnsafePathParts(normalized);
2425
}

0 commit comments

Comments
 (0)