diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/string_utils/quote/quote.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils/quote/quote.h')
-rw-r--r-- | library/cpp/string_utils/quote/quote.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/library/cpp/string_utils/quote/quote.h b/library/cpp/string_utils/quote/quote.h index 29c2bf7f89..3b7221154e 100644 --- a/library/cpp/string_utils/quote/quote.h +++ b/library/cpp/string_utils/quote/quote.h @@ -1,29 +1,29 @@ -#pragma once - -#include <util/generic/strbuf.h> +#pragma once + +#include <util/generic/strbuf.h> #include <util/generic/string.h> - + //CGIEscape*: // ' ' converted to '+', // Some punctuation and chars outside [32, 126] range are converted to %xx // Use function CgiEscapeBufLen to determine number of characters needed for 'char* to' parameter. // 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); +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) { 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) { return TStringBuf(to, CGIEscape(to, from.data(), from.size())); } inline TStringBuf CgiEscape(void* tmp, const TStringBuf s) { - return CgiEscapeBuf(static_cast<char*>(tmp), s); -} - + return CgiEscapeBuf(static_cast<char*>(tmp), s); +} + //CgiUnescape*: // Decodes '%xx' to bytes, '+' to space. // Use function CgiUnescapeBufLen to determine number of characters needed for 'char* to' parameter. @@ -37,15 +37,15 @@ 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) { - return CgiUnescapeBuf(static_cast<char*>(tmp), 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 char* from, const char* safe = "/"); char* Quote(char* to, const TStringBuf s, const char* safe = "/"); void Quote(TString& url, const char* safe = "/"); - + //UrlEscape: // Can't be used for cgi parameters ('&' character is not escaped)! // escapes only '%' not followed by two hex-digits or if forceEscape set to ture, @@ -61,12 +61,12 @@ TString UrlEscapeRet(const TStringBuf from, bool forceEscape = false); char* UrlUnescape(char* to, TStringBuf from); 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 { - return 3 * len + 1; -} - + return 3 * len + 1; +} + constexpr size_t CgiUnescapeBufLen(const size_t len) noexcept { - return len + 1; -} + return len + 1; +} |