summaryrefslogtreecommitdiffstats
path: root/net/base/escape.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-13 14:32:21 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-13 14:32:21 +0000
commitc00e68a8132fefcea614b15b002e6d4742d18fd1 (patch)
tree4f93d18efdf6c9d147a526771ab8b5b650a7c98d /net/base/escape.cc
parenta0200c5d1d5b98a8a9968b9d3aa893d7e88f59ad (diff)
downloadchromium_src-c00e68a8132fefcea614b15b002e6d4742d18fd1.zip
chromium_src-c00e68a8132fefcea614b15b002e6d4742d18fd1.tar.gz
chromium_src-c00e68a8132fefcea614b15b002e6d4742d18fd1.tar.bz2
net: Fix ASAN build my moving AppendEscapedCharForHTMLImpl above into unnamed namespace.
BUG=64263 TBR=willchan@chromium.org Review URL: http://codereview.chromium.org/8275002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/escape.cc')
-rw-r--r--net/base/escape.cc50
1 files changed, 25 insertions, 25 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc
index ff77beb..8544292 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.cc
@@ -184,6 +184,31 @@ STR UnescapeURLWithOffsetsImpl(const STR& escaped_text,
}
template <class str>
+void AppendEscapedCharForHTMLImpl(typename str::value_type c, str* output) {
+ static const struct {
+ char key;
+ const char* replacement;
+ } kCharsToEscape[] = {
+ { '<', "&lt;" },
+ { '>', "&gt;" },
+ { '&', "&amp;" },
+ { '"', "&quot;" },
+ { '\'', "&#39;" },
+ };
+ size_t k;
+ for (k = 0; k < ARRAYSIZE_UNSAFE(kCharsToEscape); ++k) {
+ if (c == kCharsToEscape[k].key) {
+ const char* p = kCharsToEscape[k].replacement;
+ while (*p)
+ output->push_back(*p++);
+ break;
+ }
+ }
+ if (k == ARRAYSIZE_UNSAFE(kCharsToEscape))
+ output->push_back(c);
+}
+
+template <class str>
str EscapeForHTMLImpl(const str& input) {
str result;
result.reserve(input.size()); // Optimize for no escaping.
@@ -241,31 +266,6 @@ std::string EscapeExternalHandlerValue(const std::string& text) {
return Escape(text, kExternalHandlerCharmap, false);
}
-template <class str>
-void AppendEscapedCharForHTMLImpl(typename str::value_type c, str* output) {
- static const struct {
- char key;
- const char* replacement;
- } kCharsToEscape[] = {
- { '<', "&lt;" },
- { '>', "&gt;" },
- { '&', "&amp;" },
- { '"', "&quot;" },
- { '\'', "&#39;" },
- };
- size_t k;
- for (k = 0; k < ARRAYSIZE_UNSAFE(kCharsToEscape); ++k) {
- if (c == kCharsToEscape[k].key) {
- const char* p = kCharsToEscape[k].replacement;
- while (*p)
- output->push_back(*p++);
- break;
- }
- }
- if (k == ARRAYSIZE_UNSAFE(kCharsToEscape))
- output->push_back(c);
-}
-
void AppendEscapedCharForHTML(char c, std::string* output) {
AppendEscapedCharForHTMLImpl(c, output);
}