Bug 1240436 - Part2: Lossy convert UTF16 to ASCII before generating nsStringInputStream. r=mayhemer

This commit is contained in:
Stone Shih 2016-04-14 18:48:37 +08:00
Родитель aa7c2fc2bd
Коммит 6759b9bad6
1 изменённых файлов: 6 добавлений и 5 удалений

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

@ -73,7 +73,8 @@ nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> inputData;
rv = NS_NewStringInputStream(getter_AddRefs(inputData), mBuffer);
NS_LossyConvertUTF16toASCII asciiData(mBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv)) return rv;
rv = mListener->OnDataAvailable(request, aContext,
@ -102,8 +103,8 @@ nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext,
mBuffer.AppendLiteral("\n</body></html>");
nsCOMPtr<nsIInputStream> inputData;
rv = NS_NewStringInputStream(getter_AddRefs(inputData), mBuffer);
NS_LossyConvertUTF16toASCII asciiData(mBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv)) return rv;
rv = mListener->OnDataAvailable(request, aContext,
@ -179,8 +180,8 @@ nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext,
if (!pushBuffer.IsEmpty()) {
nsCOMPtr<nsIInputStream> inputData;
rv = NS_NewStringInputStream(getter_AddRefs(inputData), pushBuffer);
NS_LossyConvertUTF16toASCII asciiData(pushBuffer);
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), asciiData);
if (NS_FAILED(rv))
return rv;