From 0bcd820cf448181878fe9e64a2b5726aa9bd732f Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Thu, 18 Aug 2022 20:43:11 -0300 Subject: [PATCH] [FOLD] fix bug --- include/boost/url/impl/authority_view.ipp | 9 ++++++--- include/boost/url/impl/url.ipp | 2 +- test/unit/url.cpp | 5 +++++ test/unit/url_view.cpp | 1 - 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/boost/url/impl/authority_view.ipp b/include/boost/url/impl/authority_view.ipp index a4c893a3a..153008545 100644 --- a/include/boost/url/impl/authority_view.ipp +++ b/include/boost/url/impl/authority_view.ipp @@ -269,7 +269,8 @@ int authority_view:: compare(const authority_view& other) const noexcept { - int comp = has_userinfo() - other.has_userinfo(); + auto comp = static_cast(has_userinfo()) - + static_cast(other.has_userinfo()); if ( comp != 0 ) return comp; @@ -281,7 +282,8 @@ compare(const authority_view& other) const noexcept if ( comp != 0 ) return comp; - comp = has_password() - other.has_password(); + comp = static_cast(has_password()) - + static_cast(other.has_password()); if ( comp != 0 ) return comp; @@ -301,7 +303,8 @@ compare(const authority_view& other) const noexcept if ( comp != 0 ) return comp; - comp = has_port() - other.has_port(); + comp = static_cast(has_port()) - + static_cast(other.has_port()); if ( comp != 0 ) return comp; diff --git a/include/boost/url/impl/url.ipp b/include/boost/url/impl/url.ipp index 48e6d3a78..5ecf3c851 100644 --- a/include/boost/url/impl/url.ipp +++ b/include/boost/url/impl/url.ipp @@ -262,9 +262,9 @@ relative( } else if (*it1 == dotdot) { + ++it1; if (it0 != begin0) --it0; - ++it1; } else { diff --git a/test/unit/url.cpp b/test/unit/url.cpp index b4707d6ca..15ab85321 100644 --- a/test/unit/url.cpp +++ b/test/unit/url.cpp @@ -2087,7 +2087,9 @@ class url_test // relative URL / absolute paths check("/a/path/to/somewhere/else", "/a/path/to/a", "../a"); check("/relative/sub/foo/sub/file", "/relative/path", "../../../path"); + // resolve authority check("http://google.com/baz", "http://example.org/world.html", "//example.org/world.html"); + check("http://google.com/baz", "http://example.org/world.html?q#f", "//example.org/world.html?q#f"); check("http://google.com/baz", "http:/world.html", "/world.html"); check("http://www.example.com:8080/dir/file", "http://www.example.com:8080/dir/file", ""); check("http://www.example.com:8080/dir/file", "http://www.example.com:8080/dir/file?foo=bar#abcd", "?foo=bar#abcd"); @@ -2095,6 +2097,8 @@ class url_test check("/a/path/././to/./somewhere/else", "/a/./path/./to/a", "../a"); // ".." should be normalized check("/a/path/x/../to/y/../somewhere/else", "/b/../a/path/to/a", "../a"); + // check("/../path/x/../to/y/../somewhere/else", "/a/../../path/to/a", "../a"); + check("/a/path/to/somewhere/else", "/a/path/to/a/../b", "../b"); // same parent check("/relative/file?some=query#hash", "/relative/path?blubber=1#hash1", "path?blubber=1#hash1"); // direct parent @@ -2297,6 +2301,7 @@ class url_test check("http://cppalliance.org/%2E%2E/./b/b/c/./../../g", "http://cppalliance.org/../a/g", +1); check("http://alice@cppalliance.org", "http://bob@cppalliance.org", -1); check("http://alice:passwd@cppalliance.org", "http://alice:pass@cppalliance.org", 1); + check("http://alice@cppalliance.org", "http://alice:pass@cppalliance.org", -1); check("http://alice:pass1@cppalliance.org", "http://alice:pass2@cppalliance.org", -1); check("http://cppalliance.org", "http://cppalliance.org:81", -1); check("http://cppalliance.org:80", "http://cppalliance.org:81", -1); diff --git a/test/unit/url_view.cpp b/test/unit/url_view.cpp index aa4cacd07..b3309268d 100644 --- a/test/unit/url_view.cpp +++ b/test/unit/url_view.cpp @@ -1117,7 +1117,6 @@ class url_view_test testOutput(); testCases(); testRelativePart(); - testParseOriginForm(); } };