From 15374197c2fe3dfbebf8ff19c35625cbb280dc9d Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Fri, 1 Dec 2006 04:48:05 +0000 Subject: [PATCH] Make sure the XML decl in the data we post when a document is passed to send() matches the encoding we use. Bug 361934, r=sicking, sr=biesi git-svn-id: svn://10.0.0.236/trunk@216218 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsXMLHttpRequest.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mozilla/content/base/src/nsXMLHttpRequest.cpp b/mozilla/content/base/src/nsXMLHttpRequest.cpp index 56c358ab261..6ab72140ab4 100644 --- a/mozilla/content/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/content/base/src/nsXMLHttpRequest.cpp @@ -1518,9 +1518,21 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) nsCOMPtr serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; - rv = serializer->SerializeToString(doc, serial); - if (NS_FAILED(rv)) - return rv; + // Serialize to a stream so that the encoding used will + // match the document's. + nsCOMPtr input; + nsCOMPtr output; + rv = NS_NewPipe(getter_AddRefs(input), getter_AddRefs(output), + 0, PR_UINT32_MAX); + NS_ENSURE_SUCCESS(rv, rv); + + // Empty string for encoding means to use document's current + // encoding. + rv = serializer->SerializeToStream(doc, output, EmptyCString()); + NS_ENSURE_SUCCESS(rv, rv); + + output->Close(); + postDataStream = input; } else { // nsISupportsString? nsCOMPtr wstr(do_QueryInterface(supports));