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

List:       kde-commits
Subject:    kdebase/libkonq
From:       Kevin Puetz <puetzk () iastate ! edu>
Date:       2002-12-11 21:02:55
[Download RAW message or body]

CVS commit by puetzk: 

Use KURIFilter to process invalid url's, like the code we claim 
to be a copy of.


  M +14 -23    konq_dirpart.cc   1.60


--- kdebase/libkonq/konq_dirpart.cc  #1.59:1.60
@@ -34,4 +34,5 @@
 #include <kurldrag.h>
 #include <kuserprofile.h>
+#include <kurifilter.h>
 
 #include <qapplication.h>
@@ -227,28 +228,18 @@ void KonqDirPart::mmbClicked( KFileItem 
     else
     {
-        // MMB on background, try opening clipboard URL
-        QMimeSource *data = QApplication::clipboard()->data(QClipboard::Selection);
-        if ( data->provides("text/plain") )
-        {
-            QString url;
-            if ( QTextDrag::decode( data, url ) )
-            {
-                url = url.stripWhiteSpace();
-                KURL u(url);
-                if ( u.isMalformed() ) {
-                    // some half-baked guesses for incomplete urls
-                    // (the same code is in khtml/khtml_part.cpp)
-                    if ( url.startsWith( "ftp." ) )
+        QCString plain("plain");
+        QString url = QApplication::clipboard()->text(plain,QClipboard::Selection).stripWhiteSpace();
+
+        // Check if it's a URL
+        KURIFilterData m_filterData;
+        m_filterData.setData( url );
+        if (KURIFilter::self()->filterURI(m_filterData))
                     {
-                        url.prepend( "ftp://" );
-                        u = url;
-                    }
-                    else
+            int uriType = m_filterData.uriType();
+            if ( uriType == KURIFilterData::LOCAL_FILE
+               || uriType == KURIFilterData::LOCAL_DIR
+               || uriType == KURIFilterData::NET_PROTOCOL )
                     {
-                        url.prepend( "http://" );
-                        u = url;
-                    }
-                }
-                if ( !u.isMalformed() )
+              KURL u = m_filterData.uri();
                     emit m_extension->openURLRequest( u );
             }


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

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