Skip to content

Commit ca879d8

Browse files
committed
Do not truncate beyond path start.
1 parent e0920f3 commit ca879d8

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
@@ -1157,8 +1157,15 @@ impl<'a> Parser<'a> {
11571157
".." | "%2e%2e" | "%2e%2E" | "%2E%2e" | "%2E%2E" | "%2e." | "%2E." | ".%2e"
11581158
| ".%2E" => {
11591159
debug_assert!(self.serialization.as_bytes()[segment_start - 1] == b'/');
1160-
self.serialization.truncate(segment_start - 1); // Truncate "/.."
1160+
// We dont want to truncate beyond the path start:
1161+
if segment_start - 1 > path_start {
1162+
self.serialization.truncate(segment_start - 1); // Truncate "/.."
1163+
} else {
1164+
self.serialization.truncate(segment_start); // Truncate ".."
1165+
}
1166+
11611167
self.pop_path(scheme_type, path_start);
1168+
11621169
// 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.
11631170
if ends_with_slash && !self.serialization.ends_with("/") {
11641171
self.serialization.push('/');

0 commit comments

Comments
 (0)