From: Jean-Marcel Flach Date: Wed, 8 Jul 2015 11:08:02 +0000 (+0200) Subject: Fix path interpretion in URL parser X-Git-Tag: v2.4.0~526 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65227e311bf99ba6a9f5ef623b091af7887a8aaa;p=icinga2 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 --- 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); }