[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_2_BRANCH: kdelibs/kdecore
From:       Waldo Bastian <bastian () kde ! org>
Date:       2005-03-03 13:19:45
Message-ID: 20050303131945.D163A1751E () office ! kde ! org
[Download RAW message or body]

CVS commit by waba: 

Make IDN support configurable on a per TLD basis.


  M +20 -3     kidna.cpp   1.9.4.2


--- kdelibs/kdecore/kidna.cpp  #1.9.4.1:1.9.4.2
@@ -22,4 +22,5 @@
 #include "kidna.h"
 
+#include <qstringlist.h>
 #include <kdebug.h>
 
@@ -66,4 +67,20 @@ static void KIDNA_load_lib()
 }
 
+static QStringList *KIDNA_idnDomains = 0;
+
+static bool idnSupportForHost(const QString &host)
+{
+   if (!KIDNA_idnDomains)
+   {
+      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";
+      KIDNA_idnDomains = new QStringList(QStringList::split(':', \
QString::fromLatin1(kde_use_idn).lower())); +   }
+   
+   QString tld = host.mid(host.findRev('.')+1).lower();
+   return KIDNA_idnDomains->contains(tld);
+}
+
 QCString KIDNA::toAsciiCString(const QString &idna)
 {
@@ -87,5 +104,5 @@ QCString KIDNA::toAsciiCString(const QSt
    }
 
-   if (KIDNA_lib_load_failed)
+   if (KIDNA_lib_load_failed || !idnSupportForHost(idna))
    {
       return 0; // Can't convert
@@ -133,5 +150,5 @@ QString KIDNA::toAscii(const QString &id
    }
 
-   if (KIDNA_lib_load_failed)
+   if (KIDNA_lib_load_failed || !idnSupportForHost(idna))
    {
       return QString::null; // Can't convert
@@ -165,5 +182,5 @@ QString KIDNA::toUnicode(const QString &
    }
 
-   if (KIDNA_lib_load_failed)
+   if (KIDNA_lib_load_failed || !idnSupportForHost(idna))
    {
       return idna.lower(); // Return as is


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic