зеркало из https://github.com/mozilla/gecko-dev.git
Added ACE decode function to nsIIDNService, renamed exisiting function name,
bug 110028, r=nhotta, sr=darin, a=shaver.
This commit is contained in:
Родитель
3fb226c592
Коммит
dd3f7fd5c2
|
@ -959,7 +959,7 @@ nsStandardURL::GetAsciiHost(nsACString &result)
|
|||
|
||||
if (gIDNService) {
|
||||
nsresult rv;
|
||||
rv = gIDNService->UTF8ToIDNHostName(PromiseFlatCString(Host()).get(), &mHostA);
|
||||
rv = gIDNService->ConvertUTF8toACE(PromiseFlatCString(Host()).get(), &mHostA);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
result = mHostA;
|
||||
return NS_OK;
|
||||
|
|
|
@ -47,22 +47,34 @@
|
|||
* nsIIDNService interface.
|
||||
*
|
||||
* IDN (Internationalized Domain Name) support. Provides facilities
|
||||
* for turning IDN's from UTF-8 to ACE (ASCII Compatible Encoding).
|
||||
* for manipulating IDN hostnames according to the specification set
|
||||
* forth by the IETF.
|
||||
*
|
||||
* See http://www.ietf.org/html.characters/idn-charter.html
|
||||
* or http://www.i-dns.net
|
||||
* IDN effort:
|
||||
* http://www.ietf.org/html.characters/idn-charter.html
|
||||
* http://www.i-dns.net
|
||||
*
|
||||
* IDNA specification:
|
||||
* http://search.ietf.org/internet-drafts/draft-ietf-idn-idna-06.txt
|
||||
*/
|
||||
|
||||
[scriptable, uuid(7B67747E-A8C4-4832-80C7-39EBB0C11F94)]
|
||||
interface nsIIDNService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Prepares the input hostname according to draft-ietf-idn-nameprep-05.txt.
|
||||
* Then automatically converts it into an ACE that is most likely to be
|
||||
* adopted as the standard.
|
||||
* Prepares the input hostname according to IDNA ToASCII operation,
|
||||
* the input hostname is assumed to be UTF8-encoded.
|
||||
*
|
||||
* The current input is string, but in the future where everything-is-utf8
|
||||
* this may change. See http://bugzilla.mozilla.org/show_bug.cgi?id=84186
|
||||
* The current input is string, but this may change pending Bug 84186.
|
||||
*/
|
||||
string UTF8ToIDNHostName(in string input);
|
||||
[noscript] string ConvertUTF8toACE(in string input);
|
||||
|
||||
|
||||
/**
|
||||
* This is the ToUnicode operation as specified in the IDNA proposal,
|
||||
* with an additional step to encode the result in UTF-8.
|
||||
* It takes an ACE-encoded hostname and performs ToUnicode to it, then
|
||||
* encodes the resulting string into UTF8.
|
||||
*/
|
||||
[noscript] string ConvertACEtoUTF8(in string input);
|
||||
};
|
||||
|
|
|
@ -1405,7 +1405,7 @@ nsDNSService::Lookup(const char* hostName,
|
|||
// IDN handling
|
||||
if (mIDNConverter && !nsCRT::IsAscii(hostName)) {
|
||||
nsXPIDLCString hostNameACE;
|
||||
rv = mIDNConverter->UTF8ToIDNHostName(hostName, getter_Copies(hostNameACE));
|
||||
rv = mIDNConverter->ConvertUTF8toACE(hostName, getter_Copies(hostNameACE));
|
||||
if (!hostNameACE.get()) return NS_ERROR_OUT_OF_MEMORY;
|
||||
lookup = FindOrCreateLookup(hostNameACE);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||
nsCOMPtr<nsIIDNService> converter = do_GetService(NS_IDNSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(converter, "idnSDK not installed!");
|
||||
if (converter) {
|
||||
converter->UTF8ToIDNHostName("»OÆW.¤½¥q", &buf);
|
||||
converter->ConvertUTF8toACE("»OÆW.¤½¥q", &buf);
|
||||
printf("converted = %s", buf);
|
||||
}
|
||||
return 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче