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/html/escape/escape.cpp | |
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/html/escape/escape.cpp')
-rw-r--r-- | library/cpp/html/escape/escape.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/library/cpp/html/escape/escape.cpp b/library/cpp/html/escape/escape.cpp index 4e38112ea1..5b8ed60f04 100644 --- a/library/cpp/html/escape/escape.cpp +++ b/library/cpp/html/escape/escape.cpp @@ -4,63 +4,63 @@ #include <util/generic/strbuf.h> namespace NHtml { - namespace { - struct TReplace { - char Char; - bool ForText; - TStringBuf Entity; - }; + namespace { + struct TReplace { + char Char; + bool ForText; + TStringBuf Entity; + }; TReplace Escapable[] = { {'"', false, TStringBuf(""")}, {'&', true, TStringBuf("&")}, {'<', true, TStringBuf("<")}, {'>', true, TStringBuf(">")}, - }; + }; TString EscapeImpl(const TString& value, bool isText) { - auto ci = value.begin(); - // Looking for escapable characters. - for (; ci != value.end(); ++ci) { - for (size_t i = (isText ? 1 : 0); i < Y_ARRAY_SIZE(Escapable); ++i) { - if (*ci == Escapable[i].Char) { - goto escape; - } - } + auto ci = value.begin(); + // Looking for escapable characters. + for (; ci != value.end(); ++ci) { + for (size_t i = (isText ? 1 : 0); i < Y_ARRAY_SIZE(Escapable); ++i) { + if (*ci == Escapable[i].Char) { + goto escape; + } + } } - // There is no escapable characters, so return original value. - return value; + // There is no escapable characters, so return original value. + return value; - escape: - TString tmp = TString(value.begin(), ci); + escape: + TString tmp = TString(value.begin(), ci); - for (; ci != value.end(); ++ci) { - size_t i = (isText ? 1 : 0); + for (; ci != value.end(); ++ci) { + size_t i = (isText ? 1 : 0); - for (; i < Y_ARRAY_SIZE(Escapable); ++i) { - if (*ci == Escapable[i].Char) { - tmp += Escapable[i].Entity; - break; - } - } - - if (i == Y_ARRAY_SIZE(Escapable)) { - tmp += *ci; - } + for (; i < Y_ARRAY_SIZE(Escapable); ++i) { + if (*ci == Escapable[i].Char) { + tmp += Escapable[i].Entity; + break; + } + } + + if (i == Y_ARRAY_SIZE(Escapable)) { + tmp += *ci; + } } - - return tmp; + + return tmp; } } - TString EscapeAttributeValue(const TString& value) { - return EscapeImpl(value, false); - } + TString EscapeAttributeValue(const TString& value) { + return EscapeImpl(value, false); + } - TString EscapeText(const TString& value) { - return EscapeImpl(value, true); - } + TString EscapeText(const TString& value) { + return EscapeImpl(value, true); + } } |