[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: patch: kurl
From: Waldo Bastian <bastian () kde ! org>
Date: 2000-08-28 20:37:16
[Download RAW message or body]
On Mon, 28 Aug 2000, Simon Hausmann wrote:
> > Hi,
>
> There is a small problem with the isParentOf() method of KURL. It
> currently breaks when checking if /blah/foo is a parent of /blah/foo2 .
> The current isParentOf method returns true, which however is not correct
> ;-) . The attached patch fixes it, but I'm not sure if that's the correct
> way of doing it. Please review it :-) (some KURL expert)
I think it gives a false hit for /blah/foo and /blah/foo2/test.
And what about /blah/foo/ and /blah/foo/test?
What about
if (p1.isEmpty() || p1[p1.length()-1] != '/')
p1 += '/';
return (p2.startsWith(p1));
*checking actual code*
Hm.. it seems cleanDirPath strips the leading '/' that KURL::path(1) had so
carefully added. What about the attached patch then.
Cheers,
Waldo
--
KDE/Linux, made for people, made by people.
["kurl.diff" (text/plain)]
Index: kurl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.cpp,v
retrieving revision 1.137
diff -u -r1.137 kurl.cpp
--- kurl.cpp 2000/08/14 20:01:01 1.137
+++ kurl.cpp 2000/08/28 20:40:29
@@ -739,15 +739,14 @@
m_strRef_encoded == _u.m_strRef_encoded &&
m_iPort == _u.m_iPort )
{
- QString p1( QDir::cleanDirPath( path(1) ) );
- QString p2( QDir::cleanDirPath( _u.path(1) ) );
+ QString p1( QDir::cleanDirPath( path() )+'/' );
+ QString p2( QDir::cleanDirPath( _u.path() )+'/' );
//kdDebug(126) << "p1=" << p1 << endl;
//kdDebug(126) << "p2=" << p2 << endl;
//kdDebug(126) << "p1.length()=" << p1.length() << endl;
//kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl;
- if ( p1 == p2.left( p1.length() ) )
- return true;
+ return p2.startsWith( p1 );
}
return false;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic