Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1493647
 поиск   регистрация   авторизация 
 
Группа :: Графические оболочки/KDE
Пакет: kdelibs

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: post-3.3.2-kdelibs-idn.patch


Index: kresolver.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/network/kresolver.cpp,v
retrieving revision 1.32.2.9
retrieving revision 1.32.2.10
diff -b -p -u -r1.32.2.9 -r1.32.2.10
--- kdecore/network/kresolver.cpp	25 Feb 2005 12:27:55 -0000	1.32.2.9
+++ kdecore/network/kresolver.cpp	3 Mar 2005 12:35:36 -0000	1.32.2.10
@@ -298,6 +298,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 +888,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 +911,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 +946,8 @@ QString KResolver::domainToUnicode(const
 {
   if (asciiDomain.isEmpty())
     return asciiDomain;
+  if (!idnDomains)
+    idnDomains = KResolver_initIdnDomains();
 
   QString retval;
 
@@ -939,6 +959,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
 
Index: kresolver.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/network/kresolver.h,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -b -p -u -r1.21 -r1.21.2.1
--- kdecore/network/kresolver.h	11 Jul 2004 18:46:00 -0000	1.21
+++ kdecore/network/kresolver.h	3 Mar 2005 12:35:36 -0000	1.21.2.1
@@ -926,6 +926,8 @@ private:
   KResolverPrivate* d;
   friend class KResolverResults;
   friend class ::KNetwork::Internal::KResolverManager;
+  
+  static QStringList *idnDomains;
 };
 
 }				// namespace KNetwork
Index: kio/kssl/ksslpeerinfo.cc
===================================================================
RCS file: /home/kde/kdelibs/kio/kssl/ksslpeerinfo.cc,v
retrieving revision 1.44
retrieving revision 1.44.6.2
diff -u -p -r1.44 -r1.44.6.2
--- kio/kssl/ksslpeerinfo.cc	29 May 2003 16:50:21 -0000	1.44
+++ kio/kssl/ksslpeerinfo.cc	4 Mar 2005 12:16:17 -0000	1.44.6.2
@@ -30,6 +30,9 @@
 #include <ksockaddr.h>
 #include <kextsock.h>
 #include <netsupp.h>
+#ifndef Q_WS_WIN //TODO kresolver not ported
+#include "network/kresolver.h"
+#endif
 
 #include "ksslx509map.h"
 
@@ -59,7 +62,11 @@ void KSSLPeerInfo::setPeerHost(QString r
 	while(d->peerHost.endsWith("."))
 		d->peerHost.truncate(d->peerHost.length()-1);
 
+#ifdef Q_WS_WIN //TODO kresolver not ported
 	d->peerHost = d->peerHost.lower();
+#else	
+	d->peerHost = QString::fromLatin1(KNetwork::KResolver::domainToAscii(d->peerHost));
+#endif	
 }
 
 bool KSSLPeerInfo::certMatchesAddress() {
 
design & coding: Vladimir Lettiev aka crux © 2004-2005