Properly parse URL in KUrlNavigator
Review Request #120606 - Created Oct. 16, 2014 and submitted
When using an URL with a scheme, like sftp://email@example.com/home/foo/, then KUrlNavigator doesn't properly parse it. At the beginning it tries to count the number of slashes from sftp://firstname.lastname@example.org, which is 2, then it tries to contruct buttons using names from particular sections separated by slashes, but when we use only QUrl::path() for URL above, we will always get only "/home/foo/" path and therefore we will have bigger index then the number of sections, which leads to have same URLs for all buttons. We need to parse sections from full URL including first two slashes.
Tested in dolphin and works fine now.
This looks wrong.
After this line, path can contain either a path or a URL.
Which means that transforming this back to a URL becomes rather tricky. And in particular QUrl(path) is wrong, for the case of a local file.
Try a directory with a '#' in the name to make sure the conversions are correct. It will fail in QUrl(localpath).path() because QUrl(localpath) will interpret the '#' as a query delimiter.
I don't know the KUrlNavigator code so I can't suggest a proper fix right now, but for sure this should match the code that creates the buttons in the first place (as you say), while at the same time avoid strings that can contain "a local path or a url", or if it can't avoid that, then use QUrl::fromUserInput(), which handles that correctly (just make sure that function never gets passed a relative path).