From 52a0d36bc14307017f52af1d6f77edf132d561a4 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Sat, 1 Oct 2005 03:26:03 +0000 Subject: [PATCH] Bug 309335 Unknown content type dialog(helper app dialog) shows escaped file name if it has non-ASCII char r+sr=darin git-svn-id: svn://10.0.0.236/trunk@181388 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/base/src/nsStandardURL.cpp | 10 +++++++++- .../protocol/file/src/nsFileProtocolHandler.cpp | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/mozilla/netwerk/base/src/nsStandardURL.cpp b/mozilla/netwerk/base/src/nsStandardURL.cpp index fc01ab7c0fe..d5aadfcd427 100644 --- a/mozilla/netwerk/base/src/nsStandardURL.cpp +++ b/mozilla/netwerk/base/src/nsStandardURL.cpp @@ -51,6 +51,7 @@ #include "nsIPrefBranch.h" #include "nsIPrefBranch2.h" #include "nsIIDNService.h" +#include "nsIPlatformCharset.h" #include "nsNetUtil.h" #include "prlog.h" #include "nsAutoPtr.h" @@ -2454,7 +2455,14 @@ nsStandardURL::SetFile(nsIFile *file) rv = net_GetURLSpecFromFile(file, url); if (NS_FAILED(rv)) return rv; - rv = SetSpec(url); + // We should always set the charset until bug 278161 is fixed. + nsCOMPtr platformCharset = + do_GetService(NS_PLATFORMCHARSET_CONTRACTID); + nsCAutoString charset; + if (platformCharset) + platformCharset->GetCharset(kPlatformCharsetSel_FileName, charset); + + rv = Init(mURLType, mDefaultPort, url, charset.get(), nsnull); // must clone |file| since its value is not guaranteed to remain constant if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp index 9e92d89cc34..2f3a4ac7140 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsIURL.h" +#include "nsIPlatformCharset.h" #include "nsNetUtil.h" @@ -269,8 +270,15 @@ nsFileProtocolHandler::NewURI(const nsACString &spec, specPtr = &buf; #endif - // XXX perhaps we should convert |charset| to whatever the system charset - // is so that nsStandardURL will normalize our URL string properly? + nsCAutoString urlCharset; + // We should set file system charset until bug 278161 is fixed. + nsCOMPtr platformCharset = + do_GetService(NS_PLATFORMCHARSET_CONTRACTID); + if (platformCharset) { + platformCharset->GetCharset(kPlatformCharsetSel_FileName, urlCharset); + if (!urlCharset.IsEmpty()) + charset = urlCharset.get(); + } nsresult rv = url->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, *specPtr, charset, baseURI); @@ -333,8 +341,8 @@ nsFileProtocolHandler::NewFileURI(nsIFile *file, nsIURI **result) if (!url) return NS_ERROR_OUT_OF_MEMORY; - // XXX shouldn't we set nsIURI::originCharset ?? - + // NOTE: the origin charset is assigned the value of the platform + // charset by the SetFile method. rv = url->SetFile(file); if (NS_FAILED(rv)) return rv;