Bug 1240436 - Part1: Convert UTF16 to UTF8 before generating nsStringInputStream. r=khuey

This commit is contained in:
Stone Shih 2016-04-12 16:33:53 +08:00
Родитель ff6e350e2e
Коммит aa7c2fc2bd
2 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

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

Просмотреть файл

@ -537,7 +537,8 @@ private:
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());