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

List:       kde-commits
Subject:    kdelibs/kdecore
From:       Waldo Bastian <bastian () kde ! org>
Date:       2004-03-12 16:07:43
Message-ID: 20040312160743.2EA7899A8 () office ! kde ! org
[Download RAW message or body]

CVS commit by waba: 

* Preserve leading dots in hostname (kidna regression)
* Don't encode @ in mailto: URLs


  M +20 -2     kurl.cpp   1.268
  M +9 -0      tests/kurltest.cpp   1.87


--- kdelibs/kdecore/kurl.cpp  #1.267:1.268
@@ -117,4 +117,6 @@ static QString encodeHost( const QString
   Q_UNUSED( encode_slash );
   Q_UNUSED( encoding_hint );
+  if (!segment.isEmpty() && (segment[0] == '.'))
+     return '.' + KIDNA::toAscii(segment.mid(1));
   return KIDNA::toAscii(segment);
 #else
@@ -1264,6 +1266,19 @@ QString KURL::encodedPathAndQuery( int _
      if ( _no_empty_path && tmp.isEmpty() )
         tmp = "/";
+     if (m_iUriMode == Mailto)
+     {
+        int atIndex = tmp.findRev('@');
+        if (atIndex == -1)
+           tmp = encode( tmp, false, encoding_hint );
+        else
+           tmp = encode( tmp.left(atIndex), false, encoding_hint) +
+                 '@' + 
+                 encode( tmp.mid(atIndex+1), false, encoding_hint);
+     }
+     else
+     {
      tmp = encode( tmp, false, encoding_hint );
   }
+  }
 
   // TODO apply encoding_hint to the query
@@ -1885,4 +1900,7 @@ KURL::setHost( const QString& _txt )
   case URL:
 #ifndef KDE_QT_ONLY
+   if (!_txt.isEmpty() && (_txt[0] == '.'))
+      m_strHost = "." + KIDNA::toUnicode(_txt.mid(1));
+   else
    m_strHost = KIDNA::toUnicode(_txt);
    if (m_strHost.isEmpty())

--- kdelibs/kdecore/tests/kurltest.cpp  #1.86:1.87
@@ -1,2 +1,4 @@
+#include <config.h>
+
 #include <kurl.h>
 #include <stdio.h>
@@ -38,4 +40,5 @@ int main(int argc, char *argv[])
   check( "KURL::isValid()", emptyURL.isValid() ? "TRUE":"FALSE", "FALSE");
   check( "KURL::isEmpty()", emptyURL.isEmpty() ? "TRUE":"FALSE", "TRUE");
+  check( "prettyURL()", emptyURL.prettyURL(), "");
 
   emptyURL = "";
@@ -593,5 +596,9 @@ int main(int argc, char *argv[])
   KURL amantia( "http://%E1.foo" );
   check("amantia.isValid()", amantia.isValid() ? "true" : "false", "true");
+#ifdef HAVE_IDNA_H  
+  check("amantia.url()", amantia.url(), "http://xn--80a.foo");   // Non-ascii is \
allowed in IDN domain names. +#else
   check("amantia.url()", amantia.url(), "http://"); // OK, an escaped char in a \
hostname is really evil, not sure what should happen. +#endif  
 
   KURL smb("smb://domain;username:password@server/share");
@@ -728,4 +735,6 @@ int main(int argc, char *argv[])
   url1 = "mailto:user@host.com";
   check("KURL(\"mailto:user@host.com\").uriMode()", QString::number(url1.uriMode()), \
QString::number(KURL::Mailto)); +  check("KURL(\"mailto:user@host.com\").url()", \
url1.url(), "mailto:user@host.com"); +  check("KURL(\"mailto:user@host.com\").url(0, \
106)", url1.url(0, 106), "mailto:user@host.com");  url1 = \
"data:text/plain,foobar?gazonk=flarp";  \
check("KURL(\"data:text/plain,foobar?gazonk=flarp\").uriMode()", \
QString::number(url1.uriMode()), QString::number(KURL::RawURI));


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

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