Fix relative Windows path normalization (#1261)

Fixes #1223
This commit is contained in:
Gavin Hayes 2024-08-16 14:55:49 -04:00 committed by GitHub
parent 11d9fb521d
commit 914d521090
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View file

@ -55,6 +55,19 @@ textwindows size_t __normntpath(char16_t *p, size_t n) {
// matched "/../" or "/..$"
while (j && p[j - 1] == '\\')
--j;
if (j && p[j - 1] == '.') {
// matched "." before
if (j >= 2 && p[j - 2] == '.' && //
(j == 2 || p[j - 3] == '\\')) {
// matched "^.." or "/.." before
p[++j] = '.';
++j;
continue;
} else if (j == 1 || p[j - 2] == '\\') {
// matched "^." or "/." before
continue;
}
}
while (j && p[j - 1] != '\\')
--j;
} else {