1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
$NetBSD: patch-ch,v 1.1 2005/03/17 09:46:36 markd Exp $
--- kdecore/network/kresolver.cpp.orig 2004-11-29 06:30:44.000000000 +1300
+++ kdecore/network/kresolver.cpp
@@ -32,6 +32,7 @@
#include <time.h>
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <stdlib.h>
// Qt includes
#include <qapplication.h>
@@ -298,6 +299,9 @@ void KResolverResults::virtual_hook( int
///////////////////////
// class KResolver
+QStringList *KResolver::idnDomains = 0;
+
+
// default constructor
KResolver::KResolver(QObject *parent, const char *name)
: QObject(parent, name), d(new KResolverPrivate(this))
@@ -885,10 +889,21 @@ QStrList KResolver::serviceName(int port
static QStringList splitLabels(const QString& unicodeDomain);
static QCString ToASCII(const QString& label);
static QString ToUnicode(const QString& label);
-
+
+static QStringList *KResolver_initIdnDomains()
+{
+ const char *kde_use_idn = getenv("KDE_USE_IDN");
+ if (!kde_use_idn)
+ kde_use_idn = "at:ch:cn:de:dk:kr:jp:li:no:se:tw";
+ return new QStringList(QStringList::split(':', QString::fromLatin1(kde_use_idn).lower()));
+}
+
// implement the ToAscii function, as described by IDN documents
QCString KResolver::domainToAscii(const QString& unicodeDomain)
{
+ if (!idnDomains)
+ idnDomains = KResolver_initIdnDomains();
+
QCString retval;
// RFC 3490, section 4 describes the operation:
// 1) this is a query, so don't allow unassigned
@@ -897,6 +912,10 @@ QCString KResolver::domainToAscii(const
// separators.
QStringList input = splitLabels(unicodeDomain);
+ // Do we allow IDN names for this TLD?
+ if (input.count() && !idnDomains->contains(input[input.count()-1].lower()))
+ return unicodeDomain.lower().latin1(); // No IDN allowed for this TLD
+
// 3) decide whether to enforce the STD3 rules for chars < 0x7F
// we don't enforce
@@ -928,6 +947,8 @@ QString KResolver::domainToUnicode(const
{
if (asciiDomain.isEmpty())
return asciiDomain;
+ if (!idnDomains)
+ idnDomains = KResolver_initIdnDomains();
QString retval;
@@ -939,6 +960,10 @@ QString KResolver::domainToUnicode(const
// separators.
QStringList input = splitLabels(asciiDomain);
+ // Do we allow IDN names for this TLD?
+ if (input.count() && !idnDomains->contains(input[input.count()-1].lower()))
+ return asciiDomain.lower(); // No TLDs allowed
+
// 3) decide whether to enforce the STD3 rules for chars < 0x7F
// we don't enforce
|