|
Lines 278-283
void KResolverResults::virtual_hook( int
Link Here
|
| 278 |
/////////////////////// |
278 |
/////////////////////// |
| 279 |
// class KResolver |
279 |
// class KResolver |
| 280 |
|
280 |
|
|
|
281 |
QStringList *KResolver::idnDomains = 0; |
| 282 |
|
| 283 |
|
| 281 |
// default constructor |
284 |
// default constructor |
| 282 |
KResolver::KResolver(QObject *parent, const char *name) |
285 |
KResolver::KResolver(QObject *parent, const char *name) |
| 283 |
: QObject(parent, name), d(new KResolverPrivate(this)) |
286 |
: QObject(parent, name), d(new KResolverPrivate(this)) |
|
Lines 866-876
static QStringList splitLabels(const QSt
Link Here
|
| 866 |
static QCString ToASCII(const QString& label); |
869 |
static QCString ToASCII(const QString& label); |
| 867 |
static QString ToUnicode(const QString& label); |
870 |
static QString ToUnicode(const QString& label); |
| 868 |
|
871 |
|
|
|
872 |
static QStringList *KResolver_initIdnDomains() |
| 873 |
{ |
| 874 |
const char *kde_use_idn = getenv("KDE_USE_IDN"); |
| 875 |
if (!kde_use_idn) |
| 876 |
kde_use_idn = "at:ch:cn:de:dk:kr:jp:li:no:se:tw"; |
| 877 |
return new QStringList(QStringList::split(':', QString::fromLatin1(kde_use_idn).lower())); |
| 878 |
} |
| 879 |
|
| 869 |
// implement the ToAscii function, as described by IDN documents |
880 |
// implement the ToAscii function, as described by IDN documents |
| 870 |
QCString KResolver::domainToAscii(const QString& unicodeDomain) |
881 |
QCString KResolver::domainToAscii(const QString& unicodeDomain) |
| 871 |
{ |
882 |
{ |
| 872 |
if (getenv("KDE_USE_IDN") == 0L) |
883 |
if (!idnDomains) |
| 873 |
return unicodeDomain.latin1(); |
884 |
idnDomains = KResolver_initIdnDomains(); |
| 874 |
|
885 |
|
| 875 |
QCString retval; |
886 |
QCString retval; |
| 876 |
// RFC 3490, section 4 describes the operation: |
887 |
// RFC 3490, section 4 describes the operation: |
|
Lines 880-885
QCString KResolver::domainToAscii(const
Link Here
|
| 880 |
// separators. |
891 |
// separators. |
| 881 |
QStringList input = splitLabels(unicodeDomain); |
892 |
QStringList input = splitLabels(unicodeDomain); |
| 882 |
|
893 |
|
|
|
894 |
// Do we allow IDN names for this TLD? |
| 895 |
if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) |
| 896 |
return unicodeDomain.latin1(); // No IDN allowed for this TLD |
| 897 |
|
| 883 |
// 3) decide whether to enforce the STD3 rules for chars < 0x7F |
898 |
// 3) decide whether to enforce the STD3 rules for chars < 0x7F |
| 884 |
// we don't enforce |
899 |
// we don't enforce |
| 885 |
|
900 |
|
|
Lines 911-918
QString KResolver::domainToUnicode(const
Link Here
|
| 911 |
{ |
926 |
{ |
| 912 |
if (asciiDomain.isEmpty()) |
927 |
if (asciiDomain.isEmpty()) |
| 913 |
return asciiDomain; |
928 |
return asciiDomain; |
| 914 |
if (getenv("KDE_USE_IDN") == 0L) |
929 |
if (!idnDomains) |
| 915 |
return asciiDomain;; |
930 |
idnDomains = KResolver_initIdnDomains(); |
| 916 |
|
931 |
|
| 917 |
QString retval; |
932 |
QString retval; |
| 918 |
|
933 |
|
|
Lines 924-929
QString KResolver::domainToUnicode(const
Link Here
|
| 924 |
// separators. |
939 |
// separators. |
| 925 |
QStringList input = splitLabels(asciiDomain); |
940 |
QStringList input = splitLabels(asciiDomain); |
| 926 |
|
941 |
|
|
|
942 |
// Do we allow IDN names for this TLD? |
| 943 |
if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) |
| 944 |
return asciiDomain; // No TLDs allowed |
| 945 |
|
| 927 |
// 3) decide whether to enforce the STD3 rules for chars < 0x7F |
946 |
// 3) decide whether to enforce the STD3 rules for chars < 0x7F |
| 928 |
// we don't enforce |
947 |
// we don't enforce |
| 929 |
|
948 |
|