aboutsummaryrefslogtreecommitdiff
path: root/src/Uri.cpp
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-01 15:08:21 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-01 15:08:21 -0700
commitb4cc26f831573d8dc122b4d2ba8a5f5d8d7e3773 (patch)
tree50f9b76f472908663529a1ba38b01fd51193a191 /src/Uri.cpp
parent9f9ee6af4299dbc95f5d7b814679714ba0ab5051 (diff)
Fix second bug in scheme delimiter searching
Path may also have colon, so make sure we don't scan into the path element if there is one.
Diffstat (limited to 'src/Uri.cpp')
-rw-r--r--src/Uri.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Uri.cpp b/src/Uri.cpp
index ba04298..38dbe50 100644
--- a/src/Uri.cpp
+++ b/src/Uri.cpp
@@ -466,11 +466,15 @@ namespace Uri {
bool Uri::ParseFromString(const std::string& uriString) {
// First parse the scheme.
- auto authorityDelimiter = uriString.find("//");
- if (authorityDelimiter == std::string::npos) {
- authorityDelimiter = uriString.length();
+ // Limit our search so we don't scan into the authority
+ // or path elements, because these may have the colon
+ // character as well, which we might misinterpret
+ // as the scheme delimiter.
+ auto authorityOrPathDelimiterStart = uriString.find('/');
+ if (authorityOrPathDelimiterStart == std::string::npos) {
+ authorityOrPathDelimiterStart = uriString.length();
}
- const auto schemeEnd = uriString.substr(0, authorityDelimiter).find(':');
+ const auto schemeEnd = uriString.substr(0, authorityOrPathDelimiterStart).find(':');
std::string rest;
if (schemeEnd == std::string::npos) {
impl_->scheme.clear();