Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2858)

Unified Diff: Source/wtf/text/TextEncoding.cpp

Issue 19845004: Do not normalize into NFC the values of form fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add normalizeAndEncode() without memory safety problem Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/text/TextEncoding.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/TextEncoding.cpp
diff --git a/Source/wtf/text/TextEncoding.cpp b/Source/wtf/text/TextEncoding.cpp
index 90a31d487f99ff88e57b3ff08605d7a6e8429242..eb5ded6bc3dcf4775b09f843621f215997c0cf52 100644
--- a/Source/wtf/text/TextEncoding.cpp
+++ b/Source/wtf/text/TextEncoding.cpp
@@ -72,6 +72,23 @@ CString TextEncoding::encode(const String& string, UnencodableHandling handling)
if (string.isEmpty())
return "";
+ OwnPtr<TextCodec> textCodec = newTextCodec(*this);
+ CString encodedString;
+ if (string.is8Bit())
+ encodedString = textCodec->encode(string.characters8(), string.length(), handling);
+ else
+ encodedString = textCodec->encode(string.characters16(), string.length(), handling);
+ return encodedString;
+}
+
+CString TextEncoding::normalizeAndEncode(const String& string, UnencodableHandling handling) const
+{
+ if (!m_name)
+ return CString();
+
+ if (string.isEmpty())
+ return "";
+
// Text exclusively containing Latin-1 characters (U+0000..U+00FF) is left
// unaffected by NFC. This is effectively the same as saying that all
// Latin-1 text is already normalized to NFC.
@@ -79,10 +96,6 @@ CString TextEncoding::encode(const String& string, UnencodableHandling handling)
if (string.is8Bit())
return newTextCodec(*this)->encode(string.characters8(), string.length(), handling);
- // FIXME: What's the right place to do normalization?
- // It's a little strange to do it inside the encode function.
- // Perhaps normalization should be an explicit step done before calling encode.
-
const UChar* source = string.characters16();
size_t length = string.length();
« no previous file with comments | « Source/wtf/text/TextEncoding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698