Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comments
  • Loading branch information
nineteendo committed Nov 15, 2024
commit bbbd4fe78ff2ef8584e603b7fe411bb4142b7d59
5 changes: 5 additions & 0 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize,
int sep_at_1 = SEP_OR_END(&p1[1]);
int sep_at_2 = !sep_at_1 && SEP_OR_END(&p1[2]);
if (sep_at_2 && p1[1] == L'.') {
// Parent directory
wchar_t *p3 = p2;
while (p3 != minP2 && *--p3 == SEP) { }
while (p3 != minP2 && *(p3 - 1) != SEP) { --p3; }
Expand All @@ -2572,11 +2573,15 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize,
// Absolute path, so absorb segment
p2 = p3 + 1;
} else {
// Alternative path for foo: foo/bar/..
// Alternative path for bar: foo/../bar
p2 = p3;
explicit = 1;
}
p1 += 1;
} else if (sep_at_1) {
// Current directory
// Alternative path for foo: foo/.
explicit = 1;
} else {
*p2++ = lastC = c;
Expand Down