aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/quote
diff options
context:
space:
mode:
authorandreizdor <andreizdor@yandex-team.com>2023-02-16 12:32:45 +0300
committerandreizdor <andreizdor@yandex-team.com>2023-02-16 12:32:45 +0300
commitf1eff52148cd5cf1c8b895eed1dc85c22d438eb9 (patch)
tree67cb49b4e168e6d3148248782c516438428a46fa /library/cpp/string_utils/quote
parent2d466cb51cdcc7a2de1685144bc5c2a6794d825e (diff)
downloadydb-f1eff52148cd5cf1c8b895eed1dc85c22d438eb9.tar.gz
Fix escaping cgi, according to RFC 3986 standart
https://www.ietf.org/rfc/rfc3986.txt Символ `^` не входит в допустимые символы URI
Diffstat (limited to 'library/cpp/string_utils/quote')
-rw-r--r--library/cpp/string_utils/quote/quote.cpp6
-rw-r--r--library/cpp/string_utils/quote/quote_ut.cpp10
2 files changed, 8 insertions, 8 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index a7a4749d99..6a117c424a 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -75,18 +75,18 @@ static inline const char* FixZero(const char* s) noexcept {
// '%', '&', '+', ',',
// '#', '<', '=', '>',
// '[', '\\',']', '?',
-// ':', '{', '}',
+// ':', '{', '}', '^'
// all below ' ' (0x20) and above '~' (0x7E).
// ' ' converted to '+'
static const bool chars_to_url_escape[256] = {
- // 0 1 2 3 4 5 6 7 8 9 A B C D E F
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //1
0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, //2
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, //3
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //4
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, //5
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, //5
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //6
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, //7
diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp
index 6c552b279e..9d6f56ffbb 100644
--- a/library/cpp/string_utils/quote/quote_ut.cpp
+++ b/library/cpp/string_utils/quote/quote_ut.cpp
@@ -22,27 +22,27 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) {
Y_UNIT_TEST(StringBuf) {
char tmp[100];
- UNIT_ASSERT_VALUES_EQUAL(CgiEscape(tmp, "!@#$%^&*(){}[]\" "), TStringBuf("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
+ UNIT_ASSERT_VALUES_EQUAL(CgiEscape(tmp, "!@#$%^&*(){}[]\" "), TStringBuf("!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+"));
}
Y_UNIT_TEST(StrokaRet) {
- UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
+ UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+"));
}
Y_UNIT_TEST(StrokaAppendRet) {
TString param;
AppendCgiEscaped("!@#$%^&*(){}[]\" ", param);
- UNIT_ASSERT_VALUES_EQUAL(param, TString("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
+ UNIT_ASSERT_VALUES_EQUAL(param, TString("!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+"));
TString param2 = "&param=";
AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2);
UNIT_ASSERT_VALUES_EQUAL(param2,
- TString("&param=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
+ TString("&param=!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+"));
param2.append("&param_param=");
AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2);
UNIT_ASSERT_VALUES_EQUAL(param2,
- TString("&param=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+&param_param=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
+ TString("&param=!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+&param_param=!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+"));
}
}