From 25008583680f33082baccd02f316060d3a9b9b6d Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Sat, 25 Feb 2012 23:12:55 -0800 Subject: [PATCH] Unescape URLs in mail subjects before passing them to ShellExecute. Bug 227268, r=bsmedberg, sr=biesi --- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/uriloader/exthandler/win/nsMIMEInfoWin.cpp b/uriloader/exthandler/win/nsMIMEInfoWin.cpp index 6f4774ac738..817e320c1c7 100644 --- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp +++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp @@ -55,6 +55,7 @@ #include "nsIProcess.h" #include "nsOSHelperAppService.h" #include "nsUnicharUtils.h" +#include "nsITextToSubURI.h" #define RUNDLL32_EXE L"\\rundll32.exe" @@ -266,6 +267,18 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) // extract the url spec from the url nsCAutoString urlSpec; aURL->GetAsciiSpec(urlSpec); + + // Unescape non-ASCII characters in the URL + nsCAutoString urlCharset; + nsAutoString utf16Spec; + rv = aURL->GetOriginCharset(urlCharset); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + rv = textToSubURI->UnEscapeNonAsciiURI(urlCharset, urlSpec, utf16Spec); + NS_ENSURE_SUCCESS(rv, rv); static const PRUnichar cmdVerb[] = L"open"; SHELLEXECUTEINFOW sinfo; @@ -281,8 +294,7 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) SFGAOF sfgao; // Bug 394974 - if (SUCCEEDED(SHParseDisplayName(NS_ConvertUTF8toUTF16(urlSpec).get(), - NULL, &pidl, 0, &sfgao))) { + if (SUCCEEDED(SHParseDisplayName(utf16Spec.get(),NULL, &pidl, 0, &sfgao))) { sinfo.lpIDList = pidl; sinfo.fMask |= SEE_MASK_INVOKEIDLIST; } else {