paths: Fixed dots followed by dotdots

Unlike normal files, dots (".") should not change the depth when
attempting to skip dotdot ("..") entries.

A weird nuance in the path parser, but at least it had a relatively easy
fix.

Added test_paths_dot_dotdots to prevent a regression.
This commit is contained in:
Christopher Haster
2024-11-23 01:49:08 -06:00
parent dc92dec6d3
commit 815f0d85a5
2 changed files with 195 additions and 1 deletions
+3 -1
View File
@@ -1522,7 +1522,9 @@ nextname:
break;
}
if (sufflen == 2 && memcmp(suffix, "..", 2) == 0) {
if (sufflen == 1 && memcmp(suffix, ".", 1) == 0) {
// noop
} else if (sufflen == 2 && memcmp(suffix, "..", 2) == 0) {
depth -= 1;
if (depth == 0) {
name = suffix + sufflen;