From d7dd0b4a865a8e60a8e308090fab548033fcd3da Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 21 Jan 2019 18:38:53 +0300 Subject: Fix url constructor to throw for invalid URL string representation --- libbutl/url.mxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libbutl/url.mxx b/libbutl/url.mxx index 5375698..585526a 100644 --- a/libbutl/url.mxx +++ b/libbutl/url.mxx @@ -87,7 +87,7 @@ LIBBUTL_MODEXPORT namespace butl // representations. // // Note also that we currently forbid one character schemes to support - // scheme- less (Windows) paths which can be done by + // scheme-less (Windows) paths which can be done by // url_traits::translate_scheme() (see below). (A Windows path that uses // forward slashes would be parsed as a valid authority-less URL). @@ -199,7 +199,9 @@ LIBBUTL_MODEXPORT namespace butl optional& /*fragment*/, bool& /*rootless*/) { - return scheme_type (std::move (scheme)); + return !scheme.empty () + ? optional (std::move (scheme)) + : nullopt; // Leave the URL object constructor to throw. } // Translate scheme type back to its string representation. -- cgit v1.1