aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/quote
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/string_utils/quote
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
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.h16
-rw-r--r--library/cpp/string_utils/quote/quote_ut.cpp42
3 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index e7ce5667db..e523350b80 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -166,7 +166,7 @@ TString CGIEscapeRet(const TStringBuf url) {
TString to;
to.ReserveAndResize(CgiEscapeBufLen(url.size()));
to.resize(CGIEscape(to.begin(), url.data(), url.size()) - to.data());
- return to;
+ return to;
}
TString& AppendCgiEscaped(const TStringBuf value, TString& to) {
@@ -203,7 +203,7 @@ char* Quote(char* to, const char* from, const char* safe) {
return Quote(to, FixZero(from), TCStringEndIterator(), safe);
}
-char* Quote(char* to, const TStringBuf s, const char* safe) {
+char* Quote(char* to, const TStringBuf s, const char* safe) {
return Quote(to, s.data(), s.data() + s.size(), safe);
}
@@ -239,7 +239,7 @@ TString CGIUnescapeRet(const TStringBuf from) {
TString to;
to.ReserveAndResize(CgiUnescapeBufLen(from.size()));
to.resize(CGIUnescape(to.begin(), from.data(), from.size()) - to.data());
- return to;
+ return to;
}
char* UrlUnescape(char* to, TStringBuf from) {
diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h
index 3cea6feba1..3b7221154e 100644
--- a/library/cpp/string_utils/quote/quote.h
+++ b/library/cpp/string_utils/quote/quote.h
@@ -10,17 +10,17 @@
// Returns pointer to the end of the result string
char* CGIEscape(char* to, const char* from);
char* CGIEscape(char* to, const char* from, size_t len);
-inline char* CGIEscape(char* to, const TStringBuf from) {
+inline char* CGIEscape(char* to, const TStringBuf from) {
return CGIEscape(to, from.data(), from.size());
}
void CGIEscape(TString& url);
TString CGIEscapeRet(const TStringBuf url);
TString& AppendCgiEscaped(const TStringBuf value, TString& to);
-inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) {
+inline TStringBuf CgiEscapeBuf(char* to, const TStringBuf from) {
return TStringBuf(to, CGIEscape(to, from.data(), from.size()));
}
-inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) {
+inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) {
return CgiEscapeBuf(static_cast<char*>(tmp), s);
}
@@ -33,17 +33,17 @@ char* CGIUnescape(char* to, const char* from, size_t len);
void CGIUnescape(TString& url);
TString CGIUnescapeRet(const TStringBuf from);
-inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) {
+inline TStringBuf CgiUnescapeBuf(char* to, const TStringBuf from) {
return TStringBuf(to, CGIUnescape(to, from.data(), from.size()));
}
-inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) {
+inline TStringBuf CgiUnescape(void* tmp, const TStringBuf s) {
return CgiUnescapeBuf(static_cast<char*>(tmp), s);
}
//Quote:
// Is like CGIEscape, also skips encoding of user-supplied 'safe' characters.
char* Quote(char* to, const char* from, const char* safe = "/");
-char* Quote(char* to, const TStringBuf s, const char* safe = "/");
+char* Quote(char* to, const TStringBuf s, const char* safe = "/");
void Quote(TString& url, const char* safe = "/");
//UrlEscape:
@@ -63,10 +63,10 @@ void UrlUnescape(TString& url);
TString UrlUnescapeRet(const TStringBuf from);
//*BufLen: how much characters you should allocate for 'char* to' buffers.
-constexpr size_t CgiEscapeBufLen(const size_t len) noexcept {
+constexpr size_t CgiEscapeBufLen(const size_t len) noexcept {
return 3 * len + 1;
}
-constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept {
+constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept {
return len + 1;
}
diff --git a/library/cpp/string_utils/quote/quote_ut.cpp b/library/cpp/string_utils/quote/quote_ut.cpp
index f505cf669a..6c552b279e 100644
--- a/library/cpp/string_utils/quote/quote_ut.cpp
+++ b/library/cpp/string_utils/quote/quote_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TCGIEscapeTest) {
- Y_UNIT_TEST(ReturnsEndOfTo) {
+Y_UNIT_TEST_SUITE(TCGIEscapeTest) {
+ Y_UNIT_TEST(ReturnsEndOfTo) {
char r[10];
const char* returned = CGIEscape(r, "123");
UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned);
UNIT_ASSERT_VALUES_EQUAL('\0', *returned);
}
- Y_UNIT_TEST(NotZeroTerminated) {
+ Y_UNIT_TEST(NotZeroTerminated) {
char r[] = {'1', '2', '3', '4'};
char buf[sizeof(r) * 3 + 2];
@@ -19,13 +19,13 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) {
UNIT_ASSERT_EQUAL(ret, "1234");
}
- Y_UNIT_TEST(StringBuf) {
+ Y_UNIT_TEST(StringBuf) {
char tmp[100];
UNIT_ASSERT_VALUES_EQUAL(CgiEscape(tmp, "!@#$%^&*(){}[]\" "), TStringBuf("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
}
- Y_UNIT_TEST(StrokaRet) {
+ Y_UNIT_TEST(StrokaRet) {
UNIT_ASSERT_VALUES_EQUAL(CGIEscapeRet("!@#$%^&*(){}[]\" "), TString("!@%23$%25^%26*%28%29%7B%7D%5B%5D%22+"));
}
@@ -47,14 +47,14 @@ Y_UNIT_TEST_SUITE(TCGIEscapeTest) {
}
-Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
- Y_UNIT_TEST(StringBuf) {
+Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
+ Y_UNIT_TEST(StringBuf) {
char tmp[100];
UNIT_ASSERT_VALUES_EQUAL(CgiUnescape(tmp, "!@%23$%25^%26*%28%29"), TStringBuf("!@#$%^&*()"));
}
- Y_UNIT_TEST(TestValidZeroTerm) {
+ Y_UNIT_TEST(TestValidZeroTerm) {
char r[10];
CGIUnescape(r, "1234");
@@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
}
- Y_UNIT_TEST(TestInvalidZeroTerm) {
+ Y_UNIT_TEST(TestInvalidZeroTerm) {
char r[10];
CGIUnescape(r, "%");
@@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(r, "%3u123");
}
- Y_UNIT_TEST(TestValidNotZeroTerm) {
+ Y_UNIT_TEST(TestValidNotZeroTerm) {
char r[10];
CGIUnescape(r, "123456789", 4);
@@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(r, "12=34");
}
- Y_UNIT_TEST(TestInvalidNotZeroTerm) {
+ Y_UNIT_TEST(TestInvalidNotZeroTerm) {
char r[10];
CGIUnescape(r, "%3d", 1);
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(r, "%3u1");
}
- Y_UNIT_TEST(StrokaOutParameterInplace) {
+ Y_UNIT_TEST(StrokaOutParameterInplace) {
TString s;
s = "hello%3dworld";
@@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TCGIUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(s, "");
}
- Y_UNIT_TEST(StrokaOutParameterNotInplace) {
+ Y_UNIT_TEST(StrokaOutParameterNotInplace) {
TString s, sCopy;
s = "hello%3dworld";
@@ -230,8 +230,8 @@ Y_UNIT_TEST_SUITE(TUrlEscapeTest) {
}
}
-Y_UNIT_TEST_SUITE(TUrlUnescapeTest) {
- Y_UNIT_TEST(StrokaOutParameterInplace) {
+Y_UNIT_TEST_SUITE(TUrlUnescapeTest) {
+ Y_UNIT_TEST(StrokaOutParameterInplace) {
TString s;
s = "hello%3dworld";
@@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) {
UNIT_ASSERT_VALUES_EQUAL(s, "");
}
- Y_UNIT_TEST(StrokaOutParameterNotInplace) {
+ Y_UNIT_TEST(StrokaOutParameterNotInplace) {
TString s, sCopy;
s = "hello%3dworld";
@@ -285,15 +285,15 @@ Y_UNIT_TEST_SUITE(TUrlUnescapeTest) {
}
}
-Y_UNIT_TEST_SUITE(TQuoteTest) {
- Y_UNIT_TEST(ReturnsEndOfTo) {
+Y_UNIT_TEST_SUITE(TQuoteTest) {
+ Y_UNIT_TEST(ReturnsEndOfTo) {
char r[10];
const char* returned = Quote(r, "123");
UNIT_ASSERT_VALUES_EQUAL(r + strlen("123"), returned);
UNIT_ASSERT_VALUES_EQUAL('\0', *returned);
}
- Y_UNIT_TEST(SlashIsSafeByDefault) {
+ Y_UNIT_TEST(SlashIsSafeByDefault) {
char r[100];
Quote(r, "/path;tail/path,tail/");
UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", r);
@@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) {
UNIT_ASSERT_VALUES_EQUAL("/path%3Btail/path%2Ctail/", s.c_str());
}
- Y_UNIT_TEST(SafeColons) {
+ Y_UNIT_TEST(SafeColons) {
char r[100];
Quote(r, "/path;tail/path,tail/", ";,");
UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", r);
@@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(TQuoteTest) {
UNIT_ASSERT_VALUES_EQUAL("%2Fpath;tail%2Fpath,tail%2F", s.c_str());
}
- Y_UNIT_TEST(StringBuf) {
+ Y_UNIT_TEST(StringBuf) {
char r[100];
char* end = Quote(r, "abc\0/path", "");
UNIT_ASSERT_VALUES_EQUAL("abc\0%2Fpath", TStringBuf(r, end));