diff options
author | Oleg Sidorkin <osidorkin@gmail.com> | 2022-02-10 16:49:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:36 +0300 |
commit | 5ce74d4fee2d42a4b86efc02dfdc704d458760e1 (patch) | |
tree | f16a3558ca40d453a1c6a2ed764bd75d64cffade /library/cpp/string_utils/quote | |
parent | cd33f9aa8461f8e2b0b9e68efbb6bc9856197dc9 (diff) | |
download | ydb-5ce74d4fee2d42a4b86efc02dfdc704d458760e1.tar.gz |
Restoring authorship annotation for Oleg Sidorkin <osidorkin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils/quote')
-rw-r--r-- | library/cpp/string_utils/quote/quote.cpp | 14 | ||||
-rw-r--r-- | library/cpp/string_utils/quote/quote.h | 2 | ||||
-rw-r--r-- | library/cpp/string_utils/quote/quote_ut.cpp | 34 |
3 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp index e523350b80..efbdd36903 100644 --- a/library/cpp/string_utils/quote/quote.cpp +++ b/library/cpp/string_utils/quote/quote.cpp @@ -169,13 +169,13 @@ TString CGIEscapeRet(const TStringBuf url) { return to; } -TString& AppendCgiEscaped(const TStringBuf value, TString& to) { - const size_t origLength = to.length(); - to.ReserveAndResize(origLength + CgiEscapeBufLen(value.size())); - to.resize(CGIEscape(to.begin() + origLength, value.data(), value.size()) - to.data()); - return to; -} - +TString& AppendCgiEscaped(const TStringBuf value, TString& to) { + const size_t origLength = to.length(); + to.ReserveAndResize(origLength + CgiEscapeBufLen(value.size())); + to.resize(CGIEscape(to.begin() + origLength, value.data(), value.size()) - to.data()); + return to; +} + // More general version of CGIEscape. The optional safe parameter specifies // additional characters that should not be quoted — its default value is '/'. diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h index 3b7221154e..4116126364 100644 --- a/library/cpp/string_utils/quote/quote.h +++ b/library/cpp/string_utils/quote/quote.h @@ -15,7 +15,7 @@ inline char* CGIEscape(char* to, const TStringBuf from) { } void CGIEscape(TString& url); TString CGIEscapeRet(const TStringBuf url); -TString& AppendCgiEscaped(const TStringBuf value, TString& to); +TString& AppendCgiEscaped(const TStringBuf value, TString& to); inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) { return TStringBuf(to, CGIEscape(to, from.data(), from.size())); diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp index 6c552b279e..ca33293dca 100644 --- a/library/cpp/string_utils/quote/quote_ut.cpp +++ b/library/cpp/string_utils/quote/quote_ut.cpp @@ -28,23 +28,23 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) { Y_UNIT_TEST(StrokaRet) { UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25^%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+")); - - TString param2 = "¶m="; - AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2); - UNIT_ASSERT_VALUES_EQUAL(param2, - TString("¶m=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); - - param2.append("¶m_param="); - AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2); - UNIT_ASSERT_VALUES_EQUAL(param2, - TString("¶m=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+¶m_param=!@%23$%25^%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+")); + + TString param2 = "¶m="; + AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2); + UNIT_ASSERT_VALUES_EQUAL(param2, + TString("¶m=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); + + param2.append("¶m_param="); + AppendCgiEscaped("!@#$%^&*(){}[]\" ", param2); + UNIT_ASSERT_VALUES_EQUAL(param2, + TString("¶m=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+¶m_param=!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+")); + } + } Y_UNIT_TEST_SUITE(TCGIUnescapeTest) { |