From 6b9217cc7eeb72363f33a0b1330dcdca52d25f8e Mon Sep 17 00:00:00 2001 From: Richard Walters Date: Sun, 1 Jul 2018 14:45:45 -0700 Subject: Fix bug in parsing scheme A colon may be in the authority, if present, so limit the search for scheme delimiter so we aren't scanning the authority part, when parsing the scheme. --- src/Uri.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Uri.cpp b/src/Uri.cpp index 1a82ee8..e218ecd 100644 --- a/src/Uri.cpp +++ b/src/Uri.cpp @@ -330,7 +330,11 @@ namespace Uri { bool Uri::ParseFromString(const std::string& uriString) { // First parse the scheme. - const auto schemeEnd = uriString.find(':'); + auto authorityDelimiter = uriString.find("//"); + if (authorityDelimiter == std::string::npos) { + authorityDelimiter = uriString.length(); + } + const auto schemeEnd = uriString.substr(0, authorityDelimiter).find(':'); std::string rest; if (schemeEnd == std::string::npos) { impl_->scheme.clear(); -- cgit v1.2.3