summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjingsam <jingsam@users.noreply.github.com>2016-07-04 15:26:28 +0800
committerMinh Nguyễn <mxn@1ec5.org>2016-07-04 00:26:28 -0700
commite82ecc60acfeb95ec4804ecb0964a2d695416ea1 (patch)
tree5d1f287d486d028c147cd53c188bc5f355895187 /src
parent8446a9bef201cadee8a39f0e1c008768529141c5 (diff)
downloadqtlocation-mapboxgl-e82ecc60acfeb95ec4804ecb0964a2d695416ea1.tar.gz
mapbox: URL containing query string causes infinite loop (#5554)
* correct all EXPECT_EQ(actual, expected) to EXPECT_EQ(expected, actual) * fix getMapboxURLPathname() of URL with querystring * add test for normalizeSourceURL of non-mapbox protocal * Update mapbox.cpp
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/util/mapbox.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 41959563f0..97c28c0aeb 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -20,13 +20,14 @@ bool isMapboxURL(const std::string& url) {
std::vector<std::string> getMapboxURLPathname(const std::string& url) {
std::vector<std::string> pathname;
std::size_t startIndex = protocol.length();
- while (startIndex < url.length()) {
+ std::size_t end = url.find_first_of("?#");
+ if (end == std::string::npos) {
+ end = url.length();
+ }
+ while (startIndex < end) {
std::size_t endIndex = url.find("/", startIndex);
if (endIndex == std::string::npos) {
- endIndex = url.find_first_of("?#");
- }
- if (endIndex == std::string::npos) {
- endIndex = url.length();
+ endIndex = end;
}
pathname.push_back(url.substr(startIndex, endIndex - startIndex));
startIndex = endIndex + 1;