aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/quote/quote.cpp
diff options
context:
space:
mode:
authorasavin <asavin@yandex-team.ru>2022-02-10 16:49:56 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:56 +0300
commitfa977fb6c7b468a86cf33f948fdae8e0c83d3cad (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/string_utils/quote/quote.cpp
parent0cbe97538e6c240dfb7424ac5c2173cd6a489734 (diff)
downloadydb-fa977fb6c7b468a86cf33f948fdae8e0c83d3cad.tar.gz
Restoring authorship annotation for <asavin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils/quote/quote.cpp')
-rw-r--r--library/cpp/string_utils/quote/quote.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/library/cpp/string_utils/quote/quote.cpp b/library/cpp/string_utils/quote/quote.cpp
index 9f6d8d5c9d..e523350b80 100644
--- a/library/cpp/string_utils/quote/quote.cpp
+++ b/library/cpp/string_utils/quote/quote.cpp
@@ -22,18 +22,18 @@
} while (0)
-namespace {
- class TFromHexZeroTerm {
- public:
+namespace {
+ class TFromHexZeroTerm {
+ public:
static inline char x2c(const char*& x) {
if (!IsAsciiHex((ui8)x[0]) || !IsAsciiHex((ui8)x[1]))
- return '%';
- ui8 c = 0;
+ return '%';
+ ui8 c = 0;
GETXC;
GETXC;
- return c;
- }
+ return c;
+ }
static inline char x2c(TStringBuf& x) {
if (!IsAsciiHex((ui8)x[0]) || !IsAsciiHex((ui8)x[1]))
@@ -44,24 +44,24 @@ namespace {
GETSBXC;
return c;
}
- };
-
- class TFromHexLenLimited {
- public:
- TFromHexLenLimited(const char* end)
- : End(end)
- {
- }
-
+ };
+
+ class TFromHexLenLimited {
+ public:
+ TFromHexLenLimited(const char* end)
+ : End(end)
+ {
+ }
+
inline char x2c(const char*& x) {
- if (x + 2 > End)
- return '%';
- return TFromHexZeroTerm::x2c(x);
- }
-
- private:
- const char* End;
- };
+ if (x + 2 > End)
+ return '%';
+ return TFromHexZeroTerm::x2c(x);
+ }
+
+ private:
+ const char* End;
+ };
}
static inline char d2x(unsigned x) {
@@ -122,12 +122,12 @@ static inline It1 Escape(It1 to, It2 from, It3 end, const bool* escape_map = cha
return to;
}
-template <class It1, class It2, class It3, class FromHex>
+template <class It1, class It2, class It3, class FromHex>
static inline It1 Unescape(It1 to, It2 from, It3 end, FromHex fromHex) {
(void)fromHex;
- while (from != end) {
- switch (*from) {
+ while (from != end) {
+ switch (*from) {
case '%':
++from;
*to++ = fromHex.x2c(from);
@@ -138,12 +138,12 @@ static inline It1 Unescape(It1 to, It2 from, It3 end, FromHex fromHex) {
break;
default:
*to++ = *from++;
- }
- }
- *to = 0;
- return to;
-}
-
+ }
+ }
+ *to = 0;
+ return to;
+}
+
// CGIEscape returns pointer to the end of the result string
// so as it could be possible to populate single long buffer
// with several calls to CGIEscape in a row.
@@ -216,7 +216,7 @@ void Quote(TString& url, const char* safe) {
char* CGIUnescape(char* to, const char* from) {
return Unescape(to, FixZero(from), TCStringEndIterator(), TFromHexZeroTerm());
-}
+}
char* CGIUnescape(char* to, const char* from, size_t len) {
return Unescape(to, from, from + len, TFromHexLenLimited(from + len));