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

List:       kde-bugs-dist
Subject:    [Bug 123034] KDirListener to a redirected error page causes infinite
From:       Michael Brade <brade () kde ! org>
Date:       2006-03-07 19:53:09
Message-ID: 20060307195309.24695.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=123034         
brade kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From brade kde org  2006-03-07 20:53 -------
SVN commit 516606 by brade:

Gee, maybe I should actually commit that stuff, got carried away by my Diploma 
thesis and Zack's interview :P

This commit prevents bad urls from being passed to KDirLister, mainly urls that
do not support listing. It also prevents KDirListerCache from doing redundant
work.

Ivor, please check it out and see if it still works for you the way it should.
There's a message box coming up now as well, but I cannot put appropriate text
in it due to the string freeze.

BUG:123034


 M  +39 -24    kdirlister.cpp  
 M  +2 -1      kdirlister_p.h  


--- branches/KDE/3.5/kdelibs/kio/kio/kdirlister.cpp #516605:516606
 @ -33,6 +33,7  @
 #include <kglobal.h>
 #include <kglobalsettings.h>
 #include <kstaticdeleter.h>
+#include <kprotocolinfo.h>
 
 #include "kdirlister_p.h"
 
 @ -84,7 +85,7  @
 
 // setting _reload to true will emit the old files and
 // call updateDirectory
-void KDirListerCache::listDir( KDirLister* lister, const KURL& _u,
+bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
                                bool _keep, bool _reload )
 {
   // like this we don't have to worry about trailing slashes any further
 @ -93,6 +94,9  @
   _url.adjustPath(-1);
   QString urlStr = _url.url();
 
+  if ( !lister->validURL( _url ) )
+    return false;
+
 #ifdef DEBUG_CACHE
   printDebug();
 #endif
 @ -265,8 +269,36  @
   // automatic updating of directories
   if ( lister->d->autoUpdate )
     itemU->incAutoUpdate();
+
+  return true;
 }
 
+bool KDirListerCache::validURL( const KDirLister *lister, const KURL& url ) const
+{
+  if ( !url.isValid() )
+  {
+    if ( lister->d->autoErrorHandling )
+    {
+      QString tmp = i18n("Malformed URL\n%1").arg( url.prettyURL() );
+      KMessageBox::error( lister->d->errorParent, tmp );
+    }
+    return false;
+  }
+
+  if ( !KProtocolInfo::supportsListing( url ) )
+  {
+    if ( lister->d->autoErrorHandling )
+    {
+      // TODO: this message should be changed during next string unfreeze!
+      QString tmp = i18n("Malformed URL\n%1").arg( url.prettyURL() );
+      KMessageBox::error( lister->d->errorParent, tmp );
+    }
+    return false;
+  }
+
+  return true;
+}
+
 void KDirListerCache::stop( KDirLister *lister )
 {
 #ifdef DEBUG_CACHE
 @ -1039,15 +1071,15  @
   KURL oldUrl = job->url();  // here we really need the old url!
   KURL newUrl = url;
 
+  // strip trailing slashes
+  oldUrl.adjustPath(-1);
+  newUrl.adjustPath(-1);
+
   if ( oldUrl == newUrl )
   {
     kdDebug(7004) << k_funcinfo << "New redirection url same as old, giving up." << endl;
-    killJob(job);
     return;
   }
-  // strip trailing slashes
-  oldUrl.adjustPath(-1);
-  newUrl.adjustPath(-1);
 
   kdDebug(7004) << k_funcinfo << oldUrl.prettyURL() << " -> " << newUrl.prettyURL() << endl;
 
 @ -1819,9 +1851,6  @
 
 bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
 {
-  if ( !validURL( _url ) )
-    return false;
-
   kdDebug(7003) << k_funcinfo << _url.prettyURL()
                 << " keep=" << _keep << " reload=" << _reload << endl;
 
 @ -1831,9 +1860,7  @
 
   d->changes = NONE;
 
-  s_pCache->listDir( this, _url, _keep, _reload );
-
-  return true;
+  return s_pCache->listDir( this, _url, _keep, _reload );
 }
 
 void KDirLister::stop()
 @ -2182,19 +2209,7  @
 
 bool KDirLister::validURL( const KURL& _url ) const
 {
-  if ( !_url.isValid() )
-  {
-    if ( d->autoErrorHandling )
-    {
-      QString tmp = i18n("Malformed URL\n%1").arg( _url.prettyURL() );
-      KMessageBox::error( d->errorParent, tmp );
-    }
-    return false;
-  }
-
-  // TODO: verify that this is really a directory?
-
-  return true;
+  return s_pCache->validURL( this, _url );
 }
 
 void KDirLister::handleError( KIO::Job *job )
--- branches/KDE/3.5/kdelibs/kio/kio/kdirlister_p.h #516605:516606
 @ -133,7 +133,8  @
   KDirListerCache( int maxCount = 10 );
   ~KDirListerCache();
 
-  void listDir( KDirLister *lister, const KURL &_url, bool _keep, bool _reload );
+  bool listDir( KDirLister *lister, const KURL& _url, bool _keep, bool _reload );
+  bool validURL( const KDirLister *lister, const KURL& _url ) const;
 
   // stop all running jobs for lister
   void stop( KDirLister *lister );
[prev in list] [next in list] [prev in thread] [next in thread] 

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