Skip to content

Commit 0d961c4

Browse files
committed
Do not truncate beyond path start.
1 parent ce22785 commit 0d961c4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/parser.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,15 @@ impl<'a> Parser<'a> {
11391139
".." | "%2e%2e" | "%2e%2E" | "%2E%2e" | "%2E%2E" | "%2e." | "%2E." | ".%2e"
11401140
| ".%2E" => {
11411141
debug_assert!(self.serialization.as_bytes()[segment_start - 1] == b'/');
1142-
self.serialization.truncate(segment_start - 1); // Truncate "/.."
1142+
// We dont want to truncate beyond the path start:
1143+
if segment_start - 1 > path_start {
1144+
self.serialization.truncate(segment_start - 1); // Truncate "/.."
1145+
} else {
1146+
self.serialization.truncate(segment_start); // Truncate ".."
1147+
}
1148+
11431149
self.pop_path(scheme_type, path_start);
1150+
11441151
// and then if neither c is U+002F (/), nor url is special and c is U+005C (\), append the empty string to url’s path.
11451152
if ends_with_slash && !self.serialization.ends_with("/") {
11461153
self.serialization.push('/');

0 commit comments

Comments
 (0)