Commit 26cc47d5 authored by ap@apple.com's avatar ap@apple.com
Browse files

Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=39089
        <rdar://problem/7974044> Domain names in Russian '.рф' domain are displayed as punycode

        Add a custom check for this domain. Currently, this is the only non-ASCII TLD, we'll
        investigate a more extensible solution when there are more, and we know what the
        typical restictions are.

        * Misc/WebNSURLExtras.mm:
        (allCharactersAllowedByTLDRules):
        (-[NSString _web_mapHostNameWithRange:encode:makeString:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 146e2184
2010-05-13 Alexey Proskuryakov <ap@apple.com>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=39089
<rdar://problem/7974044> Domain names in Russian '.рф' domain are displayed as punycode
Add a custom check for this domain. Currently, this is the only non-ASCII TLD, we'll
investigate a more extensible solution when there are more, and we know what the
typical restictions are.
* Misc/WebNSURLExtras.mm:
(allCharactersAllowedByTLDRules):
(-[NSString _web_mapHostNameWithRange:encode:makeString:]):
2010-05-12 Simon Fraser <simon.fraser@apple.com>
Reviewed by David Hyatt.
......
......@@ -1050,6 +1050,41 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
return YES;
}
static BOOL allCharactersAllowedByTLDRules(const UChar* buffer, int32_t length)
{
// Skip trailing dot for root domain.
if (buffer[length - 1] == '.')
--length;
if (length > 3
&& buffer[length - 3] == '.'
&& buffer[length - 2] == 0x0440 // CYRILLIC SMALL LETTER ER
&& buffer[length - 1] == 0x0444) // CYRILLIC SMALL LETTER EF
{
// Rules defined by <http://www.cctld.ru/ru/docs/rulesrf.php>. This code only checks requirements that matter for presentation purposes.
for (int32_t i = length - 4; i; --i) {
UChar ch = buffer[i];
// Only modern Russian letters, digits and dashes are allowed.
if ((ch >= 0x0430 && ch <= 0x044f)
|| ch == 0x0451
|| (ch >= '0' && ch <= '9')
|| ch == '-')
continue;
// Only check top level domain. Lower level registrars may have different rules.
if (ch == '.')
break;
return NO;
}
return YES;
}
// Not a known top level domain with special rules.
return NO;
}
// Return value of nil means no mapping is necessary.
// If makeString is NO, then return value is either nil or self to indicate mapping is necessary.
// If makeString is YES, then return value is either nil or the mapped string.
......@@ -1087,7 +1122,7 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
if (numCharactersConverted == length && memcmp(sourceBuffer, destinationBuffer, length * sizeof(UChar)) == 0) {
return nil;
}
if (!encode && !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted)) {
if (!encode && !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted) && !allCharactersAllowedByTLDRules(destinationBuffer, numCharactersConverted)) {
return nil;
}
return makeString ? (NSString *)[NSString stringWithCharacters:destinationBuffer length:numCharactersConverted] : (NSString *)self;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment