Skip to content

Commit 12283ae

Browse files
committed
Improve comments
1 parent 666d06e commit 12283ae

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

library/vulnerabilities/path-traversal/detectPathTraversal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function detectPathTraversal(
2424
// The normal check for relative path traversal will fail in this case, because transformed path does not contain ../.
2525
// Also /./ is checked by normal absolute path traversal check (if #219 is merged)
2626
// Use containsUnsafePathPartsUrl, because urls can contain a TAB, carriage return or line feed that is silently removed by the URL constructor.
27-
// Use startsWithUnsafePathUrl, because URLs can contain backward slashes that are converted to forward slashes by the URL constructor.
27+
// Use startsWithUnsafePathUrl, because URLs can contain backslashes that are converted to forward slashes by the URL constructor.
2828
if (isUrl) {
2929
const containsUnsafePath = containsUnsafePathPartsUrl(userInput);
3030
const startWithUnsafePath =
@@ -73,7 +73,7 @@ function parseAsFileUrl(path: string) {
7373
let url = path;
7474
if (!url.startsWith("file:")) {
7575
if (!url.startsWith("/") && !url.startsWith("\\")) {
76-
url = `/${url}`;
76+
url = `/${url}`; // ^^^^ URL constructor will convert backslashes to forward slashes
7777
}
7878
url = `file://${url}`;
7979
}

library/vulnerabilities/path-traversal/normalizeLikeURLConstructor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* - Remove all ASCII tab or newline from input.
66
* - An ASCII tab or newline is U+0009 TAB, U+000A LF, or U+000D CR.
77
*
8-
* Also, backward slashes are converted to forward slashes by the URL constructor.
8+
* Also, backslashes are converted to forward slashes by the URL constructor.
99
*
1010
* See https://url.spec.whatwg.org/#url-parsing
1111
*/

test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)