aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils
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
commit5dcbab5666d82d448111d17b7045c46b56ef5172 (patch)
tree7faed34125c4c1a9bf0e0707ec6daf9695d5135d /library/cpp/string_utils
parentaf7786701134cfc2bd577c1c39bbc39433b555d6 (diff)
downloadydb-5dcbab5666d82d448111d17b7045c46b56ef5172.tar.gz
Restoring authorship annotation for <samoleg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils')
-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 e523350b80..a971d9baf7 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 6c552b279e..5b20c45bbd 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];