Bug 943284 - Use FallbackEncoding instead of nsIPlatformCharset r=emk

MozReview-Commit-ID: 2pDp2RVV9zk
This commit is contained in:
Makoto Kato 2017-10-19 19:28:00 +09:00
parent 7beb660397
commit 7d1d3b65bf

View File

@ -16,12 +16,12 @@
#include "nsEscape.h"
#include "nsIDirIndex.h"
#include "nsURLHelper.h"
#include "nsIPlatformCharset.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefLocalizedString.h"
#include "nsIStringBundle.h"
#include "nsITextToSubURI.h"
#include "nsNativeCharsetUtils.h"
#include "nsString.h"
#include <algorithm>
#include "nsIChannel.h"
@ -500,13 +500,10 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
// 1. file URL may be encoded in platform charset for backward compatibility
// 2. query part may not be encoded in UTF-8 (see bug 261929)
// so try the platform's default if this is file url
if (NS_FAILED(rv) && isSchemeFile) {
nsCOMPtr<nsIPlatformCharset> platformCharset(do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv) && isSchemeFile && !NS_IsNativeUTF8()) {
auto encoding = mozilla::dom::FallbackEncoding::FromLocale();
nsAutoCString charset;
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, charset);
NS_ENSURE_SUCCESS(rv, rv);
encoding->Name(charset);
rv = mTextToSubURI->UnEscapeAndConvert(charset, titleUri, unEscapeSpec);
}
if (NS_FAILED(rv)) return rv;