Commit cb69ee19 authored by Harris Hancock's avatar Harris Hancock

Fix ..-collapsing bug in relative URL parser

parent 699d285b
...@@ -369,6 +369,9 @@ KJ_TEST("parse relative URL") { ...@@ -369,6 +369,9 @@ KJ_TEST("parse relative URL") {
parseAndCheckRelative("https://capnproto.org/foo/bar?baz=qux#corge", parseAndCheckRelative("https://capnproto.org/foo/bar?baz=qux#corge",
"/http:/grault", "/http:/grault",
"https://capnproto.org/http%3A/grault"); "https://capnproto.org/http%3A/grault");
parseAndCheckRelative("https://capnproto.org/",
"/foo/../bar",
"https://capnproto.org/bar");
} }
KJ_TEST("parse relative URL failure") { KJ_TEST("parse relative URL failure") {
......
...@@ -312,7 +312,7 @@ Maybe<Url> Url::tryParseRelative(StringPtr text) const { ...@@ -312,7 +312,7 @@ Maybe<Url> Url::tryParseRelative(StringPtr text) const {
for (;;) { for (;;) {
auto part = split(text, END_PATH_PART); auto part = split(text, END_PATH_PART);
if (part.size() == 2 && part[0] == '.' && part[1] == '.') { if (part.size() == 2 && part[0] == '.' && part[1] == '.') {
if (path.size() != 0) { if (result.path.size() != 0) {
result.path.removeLast(); result.path.removeLast();
} }
result.hasTrailingSlash = true; result.hasTrailingSlash = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment