Bug 615595. Set the form submission's mCharset to the charset we're actually using to encode the data. r=sicking

This commit is contained in:
Boris Zbarsky 2012-03-02 00:19:30 -05:00
parent 1d8182bb87
commit 93deda78c2
3 changed files with 11 additions and 8 deletions

View File

@ -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) {

View File

@ -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 \

Binary file not shown.