aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsamoleg <samoleg@yandex-team.ru>2022-02-10 16:49:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:57 +0300
commitdd0ae2c9d72d021be79622c5d39bac4be1c8313e (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8
parent5dcbab5666d82d448111d17b7045c46b56ef5172 (diff)
downloadydb-dd0ae2c9d72d021be79622c5d39bac4be1c8313e.tar.gz
Restoring authorship annotation for <samoleg@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--library/cpp/string_utils/quote/quote.cpp46
-rw-r--r--library/cpp/string_utils/quote/quote_ut.cpp198
2 files changed, 122 insertions, 122 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index a971d9baf7..e523350b80 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -223,16 +223,16 @@ char* CGIUnescape(char* to, const char* from, size_t len) {
}
void CGIUnescape(TString& url) {
- if (url.empty()) {
- return;
- }
- if (url.IsDetached()) { // in-place when refcount == 1
- char* resBegin = url.begin();
- const char* resEnd = CGIUnescape(resBegin, resBegin, url.size());
- url.resize(resEnd - resBegin);
- } else {
- url = CGIUnescapeRet(url);
- }
+ if (url.empty()) {
+ return;
+ }
+ if (url.IsDetached()) { // in-place when refcount == 1
+ char* resBegin = url.begin();
+ const char* resEnd = CGIUnescape(resBegin, resBegin, url.size());
+ url.resize(resEnd - resBegin);
+ } else {
+ url = CGIUnescapeRet(url);
+ }
}
TString CGIUnescapeRet(const TStringBuf from) {
@@ -257,25 +257,25 @@ char* UrlUnescape(char* to, TStringBuf from) {
}
void UrlUnescape(TString& url) {
- if (url.empty()) {
- return;
- }
- if (url.IsDetached()) { // in-place when refcount == 1
- char* resBegin = url.begin();
- const char* resEnd = UrlUnescape(resBegin, url);
- url.resize(resEnd - resBegin);
- } else {
- url = UrlUnescapeRet(url);
- }
+ if (url.empty()) {
+ return;
+ }
+ if (url.IsDetached()) { // in-place when refcount == 1
+ char* resBegin = url.begin();
+ const char* resEnd = UrlUnescape(resBegin, url);
+ url.resize(resEnd - resBegin);
+ } else {
+ url = UrlUnescapeRet(url);
+ }
}
TString UrlUnescapeRet(const TStringBuf from) {
TString to;
to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
to.resize(UrlUnescape(to.begin(), from) - to.data());
- return to;
-}
-
+ return to;
+}
+
char* UrlEscape(char* to, const char* from, bool forceEscape) {
from = FixZero(from);
diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp
index 5b20c45bbd..6c552b279e 100644
--- a/library/cpp/string_utils/quote/quote_ut.cpp
+++ b/library/cpp/string_utils/quote/quote_ut.cpp
@@ -123,59 +123,59 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
CGIUnescape(r, "%3u1234", 4);
UNIT_ASSERT_VALUES_EQUAL(r, "%3u1");
}
-
+
Y_UNIT_TEST(StrokaOutParameterInplace) {
TString s;
-
- s = "hello%3dworld";
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
-
- s = "+%23+";
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, " # ");
-
- s = "hello%3u";
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
-
- s = "0123456789012345";
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
-
- s = "";
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "");
- }
-
+
+ s = "hello%3dworld";
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
+
+ s = "+%23+";
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, " # ");
+
+ s = "hello%3u";
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
+
+ s = "0123456789012345";
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
+
+ s = "";
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "");
+ }
+
Y_UNIT_TEST(StrokaOutParameterNotInplace) {
TString s, sCopy;
-
- s = "hello%3dworld";
- sCopy = s;
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
-
- s = "+%23+";
- sCopy = s;
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, " # ");
-
- s = "hello%3u";
- sCopy = s;
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
-
- s = "0123456789012345";
- sCopy = s;
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
-
- s = "";
- sCopy = s;
- CGIUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "");
- }
+
+ s = "hello%3dworld";
+ sCopy = s;
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
+
+ s = "+%23+";
+ sCopy = s;
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, " # ");
+
+ s = "hello%3u";
+ sCopy = s;
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
+
+ s = "0123456789012345";
+ sCopy = s;
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
+
+ s = "";
+ sCopy = s;
+ CGIUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "");
+ }
}
Y_UNIT_TEST_SUITE(TUrlEscapeTest) {
@@ -233,58 +233,58 @@ Y_UNIT_TEST_SUITE(TUrlEscapeTest) {
Y_UNIT_TEST_SUITE(TUrlUnescapeTest) {
Y_UNIT_TEST(StrokaOutParameterInplace) {
TString s;
-
- s = "hello%3dworld";
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
-
- s = "+%23+";
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "+#+");
-
- s = "hello%3u";
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
-
- s = "0123456789012345";
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
-
- s = "";
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "");
- }
-
+
+ s = "hello%3dworld";
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
+
+ s = "+%23+";
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "+#+");
+
+ s = "hello%3u";
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
+
+ s = "0123456789012345";
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
+
+ s = "";
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "");
+ }
+
Y_UNIT_TEST(StrokaOutParameterNotInplace) {
TString s, sCopy;
-
- s = "hello%3dworld";
- sCopy = s;
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
-
- s = "+%23+";
- sCopy = s;
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "+#+");
-
- s = "hello%3u";
- sCopy = s;
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
-
- s = "0123456789012345";
- sCopy = s;
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
-
- s = "";
- sCopy = s;
- UrlUnescape(s);
- UNIT_ASSERT_VALUES_EQUAL(s, "");
- }
-}
-
+
+ s = "hello%3dworld";
+ sCopy = s;
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello=world");
+
+ s = "+%23+";
+ sCopy = s;
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "+#+");
+
+ s = "hello%3u";
+ sCopy = s;
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "hello%3u");
+
+ s = "0123456789012345";
+ sCopy = s;
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "0123456789012345");
+
+ s = "";
+ sCopy = s;
+ UrlUnescape(s);
+ UNIT_ASSERT_VALUES_EQUAL(s, "");
+ }
+}
+
Y_UNIT_TEST_SUITE(TQuoteTest) {
Y_UNIT_TEST(ReturnsEndOfTo) {
char r[10];