Fix KMountPoint::List::findByPath(const QString&): /books is not a sub-path of /book

Review Request #110225 - Created April 27, 2013 and submitted

Information
Frank Reininghaus
kdelibs
KDE/4.10
193298
Reviewers
kdelibs
dfaure, jekyllwu
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.
Works for me.

Issues

  • 3
  • 0
  • 0
  • 3
Description From Last Updated
The function would be shorter to write this way: if (parent == child) { return true; } if (parent.endsWith('/')) { ... David Faure David Faure
How can we be sure of that? We could have a mountpoint for /usr and one for /usr/local, so if ... David Faure David Faure
Strange comment - it's not. Did you mean "/books" is a child of "/books/", rather? David Faure David Faure
David Faure
Frank Reininghaus
David Faure
Commit Hook
Frank Reininghaus
Review request changed

Status: Closed (submitted)

Loading...