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

List:       kde-bugs-dist
Subject:    [Bug 173927] [patch] Crash in KDirModelPrivate::nodeForUrl() if path
From:       Frank Reininghaus <frank78ac () googlemail ! com>
Date:       2008-10-31 21:22:15
Message-ID: 20081031212215.746F2109EE () immanuel ! kde ! org
[Download RAW message or body]

http://bugs.kde.org/show_bug.cgi?id=173927


Frank Reininghaus frank78ac googlemail com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |frank78ac@googlemail.com
         AssignedTo|peter.penz@gmx.at           |faure@kde.org
          Component|general                     |general
            Product|dolphin                     |kio
            Summary|Dolphin crashes when path   |[patch] Crash in
                   |has two slashes and Folders |KDirModelPrivate::nodeForUrl
                   |panel is enabled            |() if path contains two or
                   |                            |more consecutive slashes




--- Comment #1 from Frank Reininghaus <frank78ac googlemail com>  2008-10-31 22:22:12 ---
Confirmed in trunk rev. 878290. The problem is that
KDirModelPrivate::nodeForUrl() does not handle paths with two or more
consecutive slashes properly. The patch below fixes it for me. Maybe I should
also write a simple unit test to make sure that there is no regression in the
future...

Index: kio/kio/kdirmodel.cpp
===================================================================
--- kio/kio/kdirmodel.cpp       (revision 878290)
+++ kio/kio/kdirmodel.cpp       (working copy)
@@ -186,7 +186,7 @@
     if (url.protocol() != nodeUrl.protocol())
         return 0;

-    const QString pathStr = url.path(); // no trailing slash
+    const QString pathStr = url.path().replace(QRegExp("//+"), "/"); //
pathStr has no trailing slash, but multiple slashes must be removed
     KDirModelDirNode* dirNode = m_rootNode;

     if (!pathStr.startsWith(nodeUrl.path())) {
@@ -203,7 +203,7 @@

         // E.g. pathStr is /a/b/c and nodePath is /a. We want to find the
child "b" in dirNode.
         const QString relativePath = pathStr.mid(nodePath.length());
-        Q_ASSERT(!relativePath.startsWith('/')); // huh? we need double-slash
simplification?
+        Q_ASSERT(!relativePath.startsWith('/')); // check if multiple slashes
have been removed (see above)
         const int nextSlash = relativePath.indexOf('/');
         const QString fileName = relativePath.left(nextSlash); // works even
if nextSlash==-1
         KDirModelNode* node = dirNode->m_childNodesByName.value(fileName);


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread] 

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