Review Request 110225: Fix KMountPoint::List::findByPath(const QString&): /books is not a sub-path of /book
David Faure
faure at kde.org
Sun Apr 28 09:26:06 BST 2013
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/110225/#review31692
-----------------------------------------------------------
kdecore/io/kmountpoint.cpp
<http://git.reviewboard.kde.org/r/110225/#comment23614>
The function would be shorter to write this way:
if (parent == child) {
return true;
}
if (parent.endsWith('/')) {
return child.startsWith(parent);
} else {
return child.startsWith(parent + '/');
}
This also avoids the assert below.
It creates a temp QString, though, so we need to choose between simplicity/readability and speed.
Hmm, both implementations return false erroneously if parent="/books/" and child="/books", right?
kdecore/io/kmountpoint.cpp
<http://git.reviewboard.kde.org/r/110225/#comment23609>
How can we be sure of that?
We could have a mountpoint for /usr and one for /usr/local, so if the path is /usr we could end up here with child=/usr and parent=/usr/local, and the assert will fire.
- David Faure
On April 27, 2013, 9:29 p.m., Frank Reininghaus wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/110225/
> -----------------------------------------------------------
>
> (Updated April 27, 2013, 9:29 p.m.)
>
>
> Review request for kdelibs, David Faure and Jekyll Wu.
>
>
> Description
> -------
>
> The current algorithm that tries to find out what mount point a path belongs to only checks if the first part of the string matches the mount point. The problem is that /books is then considered a path inside /book, which is obviously wrong.
>
> I propose to fix this by verifying that either the mount point ends with a '/', or the first char of the path that does not match the mount point is a '/'. I've factored this check out into a separate function to keep the code readable.
>
> Many thanks to Jekyll Wu, who analyzed this bug and found the right place in the code.
>
>
> This addresses bug 193298.
> http://bugs.kde.org/show_bug.cgi?id=193298
>
>
> Diffs
> -----
>
> kdecore/io/kmountpoint.cpp aa7a6b1
>
> Diff: http://git.reviewboard.kde.org/r/110225/diff/
>
>
> Testing
> -------
>
> Works for me.
>
>
> Thanks,
>
> Frank Reininghaus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20130428/fd5e06d7/attachment.htm>
More information about the kde-core-devel
mailing list