From 65227e311bf99ba6a9f5ef623b091af7887a8aaa Mon Sep 17 00:00:00 2001 From: Jean-Marcel Flach Date: Wed, 8 Jul 2015 13:08:02 +0200 Subject: [PATCH] Fix path interpretion in URL parser The URL parser incorrectly used to interpret the path "/" as a path "/" instead of as empty. Test cases were added. refs #9470 --- lib/base/url.cpp | 1 - test/base-url.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/base/url.cpp b/lib/base/url.cpp index d88ab7844..c456d36de 100644 --- a/lib/base/url.cpp +++ b/lib/base/url.cpp @@ -48,7 +48,6 @@ Url::Url(const String& base_url) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL: '/' expected after scheme.")); if (url.GetLength() == 1) { - m_Path.push_back("/"); return; } diff --git a/test/base-url.cpp b/test/base-url.cpp index 50f239c15..28d822967 100644 --- a/test/base-url.cpp +++ b/test/base-url.cpp @@ -64,6 +64,9 @@ BOOST_AUTO_TEST_CASE(format) url = new Url("/foo/bar/index.php?blaka"); BOOST_CHECK(new Url(url->Format())); + + url = new Url("/"); + BOOST_CHECK(url->Format() == "/"); } BOOST_AUTO_TEST_CASE(illegal_legal_strings) @@ -72,6 +75,7 @@ BOOST_AUTO_TEST_CASE(illegal_legal_strings) BOOST_CHECK_THROW(new Url("/?]=gar"), std::invalid_argument); BOOST_CHECK(new Url("/?foo=baz??&\?\?=/?")); //Valid BOOST_CHECK_THROW(new Url("/?foo=bar&foo=ba"), std::invalid_argument); + BOOST_CHECK(new Url("/")); BOOST_CHECK_THROW(new Url("/?foo=bar&[]=d"), std::invalid_argument); BOOST_CHECK_THROW(new Url("/?fo=&bar=garOA"), std::invalid_argument); }