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)

This commit is contained in:
jshin%mailaps.org 2005-02-22 18:25:12 +00:00
Родитель 66cf00a756
Коммит fd66f970be
4 изменённых файлов: 23 добавлений и 13 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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");
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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,