bug 244754 : URL is not shown in the status bar when hovering over a url-escaped URL in an encoding different from the document enecoding (r=darin, sr=bzbarsky)

git-svn-id: svn://10.0.0.236/trunk@169604 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jshin%mailaps.org
2005-02-22 18:25:12 +00:00
parent 59376921a4
commit b918fc6323
4 changed files with 23 additions and 13 deletions

View File

@@ -322,10 +322,11 @@ nsMediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
nsCOMPtr<nsITextToSubURI> textToSubURI =
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
rv = textToSubURI->UnEscapeURIForUI(docCharset, fileName, fileStr);
// UnEscapeURIForUI always succeeds
textToSubURI->UnEscapeURIForUI(docCharset, fileName, fileStr);
else
CopyUTF8toUTF16(fileName, fileStr);
}
if (fileStr.IsEmpty())
CopyUTF8toUTF16(fileName, fileStr);
}

View File

@@ -2835,11 +2835,11 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
nsCOMPtr<nsITextToSubURI> textToSubURI(
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
rv = textToSubURI->UnEscapeURIForUI(charset, spec, formatStrs[0]);
if (NS_FAILED(rv)) {
CopyASCIItoUCS2(spec, formatStrs[0]);
rv = NS_OK;
}
// UnEscapeURIForUI always succeeds
textToSubURI->UnEscapeURIForUI(charset, spec, formatStrs[0]);
else
CopyUTF8toUTF16(spec, formatStrs[0]);
rv = NS_OK;
formatStrCount = 1;
error.AssignLiteral("fileNotFound");
}

View File

@@ -52,14 +52,18 @@ interface nsITextToSubURI : nsISupports
/**
* Unescapes the given URI fragment (for UI purpose only)
* note: escaping back the result unescaped string is not guaranteed to be
* identical to the original escaped string
* Note:
* <ul>
* <li> escaping back the result (unescaped string) is not guaranteed to
* give the original escaped string
* <li> In case of a conversion error, the URI fragment (escaped) is
* assumed to be in UTF-8 and converted to AString (UTF-16)
* <li> Always succeeeds (callers don't need to do error checking)
* </ul>
*
* @param aCharset the charset to convert from
* @param aURIFragment the URI (or URI fragment) to unescape
* @return Unescaped aURIFragment converted to unicode
* @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset
* or error code of nsIUnicodeDecoder in case of covnersion failure
*/
AString unEscapeURIForUI(in ACString aCharset, in AUTF8String aURIFragment);

View File

@@ -230,7 +230,12 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeURIForUI(const nsACString & aCharset,
NS_UnescapeURL(PromiseFlatCString(aURIFragment),
esc_SkipControl | esc_AlwaysCopy, unescapedSpec);
return convertURItoUnicode(PromiseFlatCString(aCharset), unescapedSpec, PR_TRUE, _retval);
// in case of failure, return escaped URI
if (NS_FAILED(convertURItoUnicode(
PromiseFlatCString(aCharset), unescapedSpec, PR_TRUE, _retval)))
// assume UTF-8 instead of ASCII because hostname (IDN) may be in UTF-8
CopyUTF8toUTF16(aURIFragment, _retval);
return NS_OK;
}
NS_IMETHODIMP nsTextToSubURI::UnEscapeNonAsciiURI(const nsACString & aCharset,