Bug 615595. Set the form submission's mCharset to the charset we're actually using to encode the data. r=sicking
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 02 Mar 2012 00:19:30 -0500
changeset 88135 b1eb49737d05a4d89ac681a91fa0075a7846829c
parent 88134 593ae548729340f0242f98468a6823acde8da0d1
child 88136 c11552388c8bedab9bbb982938d0c41acddbf2a7
push id22171
push usermak77@bonardo.net
push dateFri, 02 Mar 2012 13:56:30 +0000
treeherderautoland@343ec916dfd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs615595
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 615595. Set the form submission's mCharset to the charset we're actually using to encode the data. r=sicking
content/html/content/src/nsFormSubmission.cpp
content/html/content/test/Makefile.in
content/html/content/test/test_bug615595.html
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -713,25 +713,18 @@ nsEncodingFormSubmission::nsEncodingForm
 {
   nsCAutoString charset(aCharset);
   // canonical name is passed so that we just have to check against
   // *our* canonical names listed in charsetaliases.properties
   if (charset.EqualsLiteral("ISO-8859-1")) {
     charset.AssignLiteral("windows-1252");
   }
 
-  // use UTF-8 for UTF-16* (per WHATWG and existing practice of
-  // MS IE/Opera). 
-  if (StringBeginsWith(charset, NS_LITERAL_CSTRING("UTF-16"))) {
-    charset.AssignLiteral("UTF-8");
-  }
-
   if (!(charset.EqualsLiteral("UTF-8") || charset.EqualsLiteral("gb18030"))) {
-    nsAutoString charsetUtf16;
-    CopyUTF8toUTF16(charset, charsetUtf16);
+    NS_ConvertUTF8toUTF16 charsetUtf16(charset);
     const PRUnichar* charsetPtr = charsetUtf16.get();
     SendJSWarning(aOriginatingElement ? aOriginatingElement->GetOwnerDocument()
                                       : nsnull,
                   "CannotEncodeAllUnicode",
                   &charsetPtr,
                   1);
   }
 
@@ -864,16 +857,25 @@ GetSubmissionFromForm(nsGenericHTMLEleme
   } else {
     GetEnumAttr(aForm, nsGkAtoms::method, &method);
   }
 
   // Get charset
   nsCAutoString charset;
   GetSubmitCharset(aForm, charset);
 
+  // We now have a canonical charset name, so we only have to check it
+  // against canonical names.
+
+  // use UTF-8 for UTF-16* (per WHATWG and existing practice of
+  // MS IE/Opera).
+  if (StringBeginsWith(charset, NS_LITERAL_CSTRING("UTF-16"))) {
+    charset.AssignLiteral("UTF-8");
+  }
+
   // Choose encoder
   if (method == NS_FORM_METHOD_POST &&
       enctype == NS_FORM_ENCTYPE_MULTIPART) {
     *aFormSubmission = new nsFSMultipartFormData(charset, aOriginatingElement);
   } else if (method == NS_FORM_METHOD_POST &&
              enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
     *aFormSubmission = new nsFSTextPlain(charset, aOriginatingElement);
   } else {
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -267,16 +267,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug660663.html \
 		test_bug664299.html \
 		test_bug666200.html \
 		test_bug666666.html \
 		test_bug669012.html \
 		test_bug674558.html \
 		test_bug583533.html \
 		test_restore_from_parser_fragment.html \
+		test_bug615595.html \
 		test_bug617528.html \
 		test_bug660959-1.html \
 		test_bug660959-2.html \
 		test_bug660959-3.html \
 		test_checked.html \
 		test_bug677658.html \
 		test_bug677463.html \
 		test_bug682886.html \
new file mode 100644
index 0000000000000000000000000000000000000000..3acaad9e0c25cbb16dd60fcbe6facf1c4aa8ef1f
GIT binary patch
literal 2692
zc$~df+iuf95S{0I#nu9vqGGE;AZQaRpsjdlMWq%Yo~o_w5JTcvvC~peznMP(&dl!G
z>%^r6A+)kHdzmw5XU~rF<0lPhjrQm*y{1$8K*zLCir&CJqC<K?J<N}(qA5*mZ;c+I
z^<=c7f=b$^2<@B}^pU<&hLsc26vAiL>d$D76%jnfurKM%`h*nYozX6ygogB#w&)4k
zb38qX=6IyQNu;OH28fV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