aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2025-07-25 04:52:10 +0300
committerlevlam <levlam@telegram.org>2025-07-25 04:52:10 +0300
commit2e88790a2dc7af60a64b8eb4fcc906ce31823dab (patch)
tree01a32ad641795f42b224e2e6c372fcc76060fbd6
parent60c7dd50e85f03656a030d0843a5e95ee692f008 (diff)
Fix parse_url_query.
-rw-r--r--tdutils/td/utils/HttpUrl.cpp4
-rw-r--r--tdutils/test/HttpUrl.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/tdutils/td/utils/HttpUrl.cpp b/tdutils/td/utils/HttpUrl.cpp
index 55869002a..518bdb52e 100644
--- a/tdutils/td/utils/HttpUrl.cpp
+++ b/tdutils/td/utils/HttpUrl.cpp
@@ -6,6 +6,7 @@
//
#include "td/utils/HttpUrl.h"
+#include "td/utils/algorithm.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
@@ -205,7 +206,8 @@ HttpUrlQuery parse_url_query(Slice query) {
}
HttpUrlQuery result;
- result.path_ = full_split(url_decode(query.substr(0, path_size), false), '/');
+ result.path_ = transform(full_split(query.substr(0, path_size), '/'),
+ [](Slice &&segment) { return url_decode(segment, false); });
while (!result.path_.empty() && result.path_.back().empty()) {
result.path_.pop_back();
}
diff --git a/tdutils/test/HttpUrl.cpp b/tdutils/test/HttpUrl.cpp
index 1b26c7ec4..463a598d6 100644
--- a/tdutils/test/HttpUrl.cpp
+++ b/tdutils/test/HttpUrl.cpp
@@ -134,6 +134,8 @@ TEST(HttpUrl, parse_url_query) {
test_parse_url_query("//", {}, {});
test_parse_url_query("///?a", {}, {{"a", ""}});
test_parse_url_query("/a/b/c/", {"a", "b", "c"}, {});
+ test_parse_url_query("/a+/++b+/c/", {"a+", "++b+", "c"}, {});
+ test_parse_url_query("/a%2f/%2F%2Fb%2f/c/", {"a/", "//b/", "c"}, {});
test_parse_url_query("/a/b/?c/", {td::string("a"), td::string("b")}, {{"c/", ""}});
test_parse_url_query("?", {}, {});
test_parse_url_query("???", {}, {{"??", ""}});