forked from svrjs/svrjs
Change lookahead token order in two URL sanitation regular expressions
This commit is contained in:
parent
ae630a1625
commit
bd5ab63954
1 changed files with 1 additions and 1 deletions
2
svr.js
2
svr.js
|
@ -1311,7 +1311,7 @@ function sanitizeURL(resource) {
|
|||
// Convert backslashes to slashes and remove duplicate slashes
|
||||
sanitizedResource = sanitizedResource.replace(/\\/g, "/").replace(/\/+/g, "/");
|
||||
// Handle relative navigation (e.g., "/./", "/../", "../", "./"), also remove trailing dots in paths
|
||||
sanitizedResource = sanitizedResource.replace(/\/\.(?:\.{2,})?(?=$|\/)/g, "").replace(/([^.\/])\.+(?=$|\/)/g, "$1");
|
||||
sanitizedResource = sanitizedResource.replace(/\/\.(?:\.{2,})?(?=\/|$)/g, "").replace(/([^.\/])\.+(?=\/|$)/g, "$1");
|
||||
while (sanitizedResource.match(/\/(?!\.\.\/)[^\/]+\/\.\.(?=\/|$)/g)) {
|
||||
sanitizedResource = sanitizedResource.replace(/\/(?!\.\.\/)[^\/]+\/\.\.(?=\/|$)/g, "");
|
||||
}
|
||||
|
|
Reference in a new issue