summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-02-13 12:41:30 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-02-13 17:23:20 +0100
commitf97e36acc80cda33eb8000e88fa02cfdc53009e8 (patch)
treede78a6007a971a1f368df147bb84913acd338d78 /src
parent090fb92fbf073728e1a9b5196e880a216f11e109 (diff)
downloadqtlocation-mapboxgl-f97e36acc80cda33eb8000e88fa02cfdc53009e8.tar.gz
[core] add tests for user/password, port, trailing dot, and IPv4/IPv6 address parsing
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/util/url.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mbgl/util/url.cpp b/src/mbgl/util/url.cpp
index 0a7d096ec0..3f36bc676f 100644
--- a/src/mbgl/util/url.cpp
+++ b/src/mbgl/util/url.cpp
@@ -89,8 +89,10 @@ URL::URL(const std::string& str)
return { queryPos, (hashPos != std::string::npos ? hashPos : str.size()) - queryPos };
}()),
scheme([&]() -> Segment {
- auto schemeEnd = str.find(':');
- return { 0, schemeEnd == std::string::npos || schemeEnd > query.first ? 0 : schemeEnd };
+ if (str.empty() || !isAlphaCharacter(str.front())) return { 0, 0 };
+ size_t schemeEnd = 0;
+ while (schemeEnd < query.first && isSchemeCharacter(str[schemeEnd])) ++schemeEnd;
+ return { 0, str[schemeEnd] == ':' ? schemeEnd : 0 };
}()),
domain([&]() -> Segment {
auto domainPos = scheme.first + scheme.second;