Bug 1240282 - Don't use NS_LossyConvertUTF16toASCII for URI. r?jimm
We should use GetAsciiSpec for idn and non-ASCII path
MozReview-Commit-ID: EjldSMJYUDg
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -1124,42 +1124,42 @@ nsDataObj :: GetFileDescriptorInternetSh
HRESULT
nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG )
{
static const char * kShellIconPref = "browser.shell.shortcutFavicons";
nsAutoString url;
if ( NS_FAILED(ExtractShortcutURL(url)) )
return E_OUTOFMEMORY;
- // will need to change if we ever support iDNS
- nsAutoCString asciiUrl;
- LossyCopyUTF16toASCII(url, asciiUrl);
-
- nsCOMPtr<nsIFile> icoFile;
nsCOMPtr<nsIURI> aUri;
NS_NewURI(getter_AddRefs(aUri), url);
+ nsresult rv;
+ nsAutoCString asciiUrl;
+ rv = aUri->GetAsciiSpec(asciiUrl);
+ if (NS_FAILED(rv)) {
+ return E_FAIL;
+ }
+
const char *shortcutFormatStr;
int totalLen;
nsCString path;
if (!Preferences::GetBool(kShellIconPref, true) ||
!IsVistaOrLater()) {
shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n";
const int formatLen = strlen(shortcutFormatStr) - 2; // don't include %s
totalLen = formatLen + asciiUrl.Length(); // don't include null character
} else {
nsCOMPtr<nsIFile> icoFile;
- nsCOMPtr<nsIURI> aUri;
- NS_NewURI(getter_AddRefs(aUri), url);
nsAutoString aUriHash;
mozilla::widget::FaviconHelper::ObtainCachedIconFile(aUri, aUriHash, mIOThread, true);
- nsresult rv = mozilla::widget::FaviconHelper::GetOutputIconPath(aUri, icoFile, true);
+ rv = mozilla::widget::FaviconHelper::GetOutputIconPath(aUri, icoFile, true);
NS_ENSURE_SUCCESS(rv, E_FAIL);
rv = icoFile->GetNativePath(path);
NS_ENSURE_SUCCESS(rv, E_FAIL);
shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n"
"IDList=\r\nHotKey=0\r\nIconFile=%s\r\n"
"IconIndex=0\r\n";
const int formatLen = strlen(shortcutFormatStr) - 2 * 2; // no %s twice