diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 14:19:27 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 14:19:27 +0000 |
commit | a0200c5d1d5b98a8a9968b9d3aa893d7e88f59ad (patch) | |
tree | 5769d50bd1828cd576a5e5313690e232e02c9439 /net | |
parent | c72e24894a880d67ccc35ee67c85b784f1e829bb (diff) | |
download | chromium_src-a0200c5d1d5b98a8a9968b9d3aa893d7e88f59ad.zip chromium_src-a0200c5d1d5b98a8a9968b9d3aa893d7e88f59ad.tar.gz chromium_src-a0200c5d1d5b98a8a9968b9d3aa893d7e88f59ad.tar.bz2 |
net: Move EscapeForHTML() functions into net namespace.
BUG=64263
TEST=None
R=willchan@chromium.org
Review URL: http://codereview.chromium.org/8256006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/escape.cc | 24 | ||||
-rw-r--r-- | net/base/escape.h | 8 |
2 files changed, 16 insertions, 16 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc index 3ca41f9..ff77beb 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -183,6 +183,17 @@ STR UnescapeURLWithOffsetsImpl(const STR& escaped_text, return result; } +template <class str> +str EscapeForHTMLImpl(const str& input) { + str result; + result.reserve(input.size()); // Optimize for no escaping. + + for (typename str::const_iterator i = input.begin(); i != input.end(); ++i) + AppendEscapedCharForHTMLImpl(*i, &result); + + return result; +} + } // namespace // Everything except alphanumerics and !'()*-._~ @@ -259,16 +270,7 @@ void AppendEscapedCharForHTML(char c, std::string* output) { AppendEscapedCharForHTMLImpl(c, output); } -template <class str> -str EscapeForHTMLImpl(const str& input) { - str result; - result.reserve(input.size()); // optimize for no escaping - - for (typename str::const_iterator it = input.begin(); it != input.end(); ++it) - AppendEscapedCharForHTMLImpl(*it, &result); - - return result; -} +namespace net { std::string EscapeForHTML(const std::string& input) { return EscapeForHTMLImpl(input); @@ -278,8 +280,6 @@ string16 EscapeForHTML(const string16& input) { return EscapeForHTMLImpl(input); } -namespace net { - std::string UnescapeURLComponent(const std::string& escaped_text, UnescapeRule::Type rules) { return UnescapeURLWithOffsetsImpl(escaped_text, rules, NULL); diff --git a/net/base/escape.h b/net/base/escape.h index eede454..45f2ddf 100644 --- a/net/base/escape.h +++ b/net/base/escape.h @@ -39,10 +39,6 @@ NET_EXPORT std::string EscapeExternalHandlerValue(const std::string& text); // the character would be interpretted as an HTML delimiter. NET_EXPORT void AppendEscapedCharForHTML(char c, std::string* output); -// Escape chars that might cause this text to be interpretted as HTML tags. -NET_EXPORT std::string EscapeForHTML(const std::string& text); -NET_EXPORT string16 EscapeForHTML(const string16& text); - // Unescaping ------------------------------------------------------------------ class UnescapeRule { @@ -87,6 +83,10 @@ class UnescapeRule { namespace net { +// Escape chars that might cause this text to be interpretted as HTML tags. +NET_EXPORT std::string EscapeForHTML(const std::string& text); +NET_EXPORT string16 EscapeForHTML(const string16& text); + // Unescapes |escaped_text| and returns the result. // Unescaping consists of looking for the exact pattern "%XX", where each X is // a hex digit, and converting to the character with the numerical value of |