Bug 1240436 - Part1: Convert UTF16 to UTF8 before generating nsStringInputStream. r=khuey
authorStone Shih <sshih@mozilla.com>
Tue, 12 Apr 2016 16:33:53 +0800
changeset 317619 0abedbe00975c6b31535adb94a2c83298face000
parent 317618 da6890d34fd30dd5259d889203d6a55b29a7243c
child 317620 e9cdedc9c456d1380baec15475e48a9c98811682
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1240436
milestone48.0a1
Bug 1240436 - Part1: Convert UTF16 to UTF8 before generating nsStringInputStream. r=khuey
dom/fetch/Fetch.cpp
dom/workers/ServiceWorkerScriptCache.cpp
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -446,17 +446,17 @@ ExtractFromUSVString(const nsString& aSt
 nsresult
 ExtractFromURLSearchParams(const URLSearchParams& aParams,
                            nsIInputStream** aStream,
                            nsCString& aContentType)
 {
   nsAutoString serialized;
   aParams.Stringify(serialized);
   aContentType = NS_LITERAL_CSTRING("application/x-www-form-urlencoded;charset=UTF-8");
-  return NS_NewStringInputStream(aStream, serialized);
+  return NS_NewCStringInputStream(aStream, NS_ConvertUTF16toUTF8(serialized));
 }
 } // namespace
 
 nsresult
 ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams& aBodyInit,
                           nsIInputStream** aStream,
                           nsCString& aContentType)
 {
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -532,17 +532,18 @@ private:
   WriteToCache(Cache* aCache)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aCache);
     MOZ_ASSERT(mState == WaitingForOpen);
 
     ErrorResult result;
     nsCOMPtr<nsIInputStream> body;
-    result = NS_NewStringInputStream(getter_AddRefs(body), mCN->Buffer());
+    result = NS_NewCStringInputStream(getter_AddRefs(body),
+                                      NS_ConvertUTF16toUTF8(mCN->Buffer()));
     if (NS_WARN_IF(result.Failed())) {
       MOZ_ASSERT(!result.IsErrorWithMessage());
       Fail(result.StealNSResult());
       return;
     }
 
     RefPtr<InternalResponse> ir =
       new InternalResponse(200, NS_LITERAL_CSTRING("OK"));