From 62f1a600745362a09e55c64cced3a99657c02adb Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 2 Mar 2012 00:19:30 -0500 Subject: [PATCH] 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 | 18 ++++++++++-------- content/html/content/test/Makefile.in | 1 + content/html/content/test/test_bug615595.html | Bin 0 -> 2692 bytes 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 content/html/content/test/test_bug615595.html diff --git a/content/html/content/src/nsFormSubmission.cpp b/content/html/content/src/nsFormSubmission.cpp index 1ab6e696125..af10d9e0f1e 100644 --- a/content/html/content/src/nsFormSubmission.cpp +++ b/content/html/content/src/nsFormSubmission.cpp @@ -718,15 +718,8 @@ nsEncodingFormSubmission::nsEncodingFormSubmission(const nsACString& aCharset, 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, @@ -869,6 +862,15 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm, 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) { diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in index 6a9545e3be6..4cfa2985409 100644 --- a/content/html/content/test/Makefile.in +++ b/content/html/content/test/Makefile.in @@ -272,6 +272,7 @@ _TEST_FILES = \ 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 \ diff --git a/content/html/content/test/test_bug615595.html b/content/html/content/test/test_bug615595.html new file mode 100644 index 0000000000000000000000000000000000000000..3acaad9e0c25cbb16dd60fcbe6facf1c4aa8ef1f GIT binary patch literal 2692 zcmcJRZ%-3J5XR?qKgH3gfWcmf(I^&(e=xp~NCL+AswwT&qUG9nM-dI5*>9l!p55Et z7E0AbvuST{cW36AnP+D2$4_h9ioLKm_S}x_y&c$|CH9K>zP+{`Yp_4G(oStuy{*_i zM#HU^HnGCCEM*+qnSHRYcEZV#b*+WWcpU}2kM}h|# z9?N@0^uk40dCnLmtBG3;5t5f*SV_@a+<<)ObPoPFE+KMalh>J6j7=Smz??R$8^fZD zYFF$Lhr~@`l@DU3I4s|VJ;tJH`2V~YXZOKb*VE1H>{gykKVfHsV2;K^s!6;#0E1%NV(vT1JRXlp zOq;l>jk&Ulgy)Jd_gMx54?+Gs*2g6zolTRWqlV+iISfw$I~biJz}1_ zcRMDz<~gy&zOt0#ah(tK`_!GB&RC_|uJax0%*(W~@o)N|d}?6(E+d)syXCz( zai>!!xu{#VxMjLTsifPf!|%~`LTC1?Vx1~wXlu4^Pn;%oiaxjB7}-8DQ^$#t69YJw zM@*MYV&9Nbrln^Mi7_Y698Z-8^&@{b`5MW}#JHD+pDxajskMpJHRomjp09|_e&eLP& zz3{hMxbfo~KJE(Ftp@9V|NLDK+QoO@LAH6`=KJS9|4(5`W_P#&Le~5jMTeM&OzDea zo$Ot`ZJXp(o%D=o_KBLZF7D{|6#Enxb;)FAIpKtIaP@vw<;I$hD=q5g`X193t)ZN9u0a>