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-04 00:26:28 -0700 |
commit | e82ecc60acfeb95ec4804ecb0964a2d695416ea1 (patch) | |
tree | 5d1f287d486d028c147cd53c188bc5f355895187 /src/mbgl/util/mapbox.cpp | |
parent | 8446a9bef201cadee8a39f0e1c008768529141c5 (diff) | |
download | qtlocation-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/mbgl/util/mapbox.cpp')
-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; |