Bug 1488115 - Part 1: Remove nsIUTF8ConverterService::ConvertURISpecToUTF8() since it is unused; r=hsivonen

Differential Revision: https://phabricator.services.mozilla.com/D4872
This commit is contained in:
Ehsan Akhgari 2018-09-03 10:22:43 -04:00
parent 08f05bd051
commit 1a28ba6ef6
2 changed files with 0 additions and 61 deletions

View File

@ -38,31 +38,5 @@ interface nsIUTF8ConverterService : nsISupports
in string aCharset,
in boolean aSkipCheck,
[optional] in boolean aAllowSubstitution);
/* XXX : To-be-added. convertStringFromUTF8 */
/**
* Ensure that |aSpec| (after URL-unescaping it) is encoded in UTF-8.
* If not, convert it to UTF-8, assuming it's encoded in |aCharset|,
* and return the result.
*
* <p>Make sure that all characters outside US-ASCII in your input spec
* are url-escaped if your spec is not in UTF-8 (before url-escaping)
* because the presence of non-ASCII characters is <strong>blindly</strong>
* regarded as an indication that your input spec is in unescaped UTF-8
* and it will be returned without further processing. No valid spec
* going around in Mozilla code would break this assumption.
*
* <p>XXX The above may change in the future depending on the usage pattern.
*
* @param aSpec an url-escaped URI spec to ensure its UTF8ness
* @param aCharset the charset to convert from if |aSpec| is not in UTF-8
* @return the converted spec in UTF-8.
* @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset
* or NS_ERROR_UDEC_ILLEGALINPUT in case of conversion failure
*/
AUTF8String convertURISpecToUTF8(in ACString aSpec,
in string aCharset);
};

View File

@ -72,38 +72,3 @@ nsUTF8ConverterService::ConvertStringToUTF8(const nsACString& aString,
return rv;
}
NS_IMETHODIMP
nsUTF8ConverterService::ConvertURISpecToUTF8(const nsACString& aSpec,
const char* aCharset,
nsACString& aUTF8Spec)
{
// assume UTF-8 if the spec contains unescaped non-ASCII characters.
// No valid spec in Mozilla would break this assumption.
if (!IsASCII(aSpec)) {
aUTF8Spec = aSpec;
return NS_OK;
}
aUTF8Spec.Truncate();
nsAutoCString unescapedSpec;
// NS_UnescapeURL does not fill up unescapedSpec unless there's at least
// one character to unescape.
bool written = NS_UnescapeURL(PromiseFlatCString(aSpec).get(),
aSpec.Length(),
esc_OnlyNonASCII,
unescapedSpec);
if (!written) {
aUTF8Spec = aSpec;
return NS_OK;
}
// return if ASCII only or escaped UTF-8
if (IsASCII(unescapedSpec) || IsUTF8(unescapedSpec)) {
aUTF8Spec = unescapedSpec;
return NS_OK;
}
return ToUTF8(unescapedSpec, aCharset, true, aUTF8Spec);
}