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-19 12:22:34 -0700
commit12b431ee03b09643643be88da439283d873a6694 (patch)
tree51924c4d9a9eb152004bf60dcacd523e89f42a67 /src
parent223e3b34fc4001e0769dbf7d73dbdc1c02dddaa9 (diff)
downloadqtlocation-mapboxgl-12b431ee03b09643643be88da439283d873a6694.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 Cherry-picked from e82ecc60acfeb95ec4804ecb0964a2d695416ea1.
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;