diff options
author | jingsam <jingsam@users.noreply.github.com> | 2016-07-04 15:26:28 +0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-07-19 12:22:34 -0700 |
commit | 12b431ee03b09643643be88da439283d873a6694 (patch) | |
tree | 51924c4d9a9eb152004bf60dcacd523e89f42a67 /src | |
parent | 223e3b34fc4001e0769dbf7d73dbdc1c02dddaa9 (diff) | |
download | qtlocation-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.cpp | 11 |
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; |