From aa7c2fc2bdc1312c96a5bf2c3f3229f2a1eac0d7 Mon Sep 17 00:00:00 2001 From: Stone Shih Date: Tue, 12 Apr 2016 16:33:53 +0800 Subject: [PATCH] Bug 1240436 - Part1: Convert UTF16 to UTF8 before generating nsStringInputStream. r=khuey --- dom/fetch/Fetch.cpp | 2 +- dom/workers/ServiceWorkerScriptCache.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index 39b31065c5fb..5f192f72aafa 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -451,7 +451,7 @@ ExtractFromURLSearchParams(const URLSearchParams& aParams, 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 diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorkerScriptCache.cpp index fa25947d4959..5ffec43aa2db 100644 --- a/dom/workers/ServiceWorkerScriptCache.cpp +++ b/dom/workers/ServiceWorkerScriptCache.cpp @@ -537,7 +537,8 @@ private: ErrorResult result; nsCOMPtr 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());