Bug 144220 - kfiledialog used for opening a file does not handle bad user input properly
Summary: kfiledialog used for opening a file does not handle bad user input properly
Status: RESOLVED DUPLICATE of bug 317513
Alias: None
Product: kfile
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-14 18:54 UTC by Shriramana Sharma
Modified: 2018-04-11 21:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shriramana Sharma 2007-04-14 18:54:20 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

I will start out with an example in Kate. I think the problem is with kdelibs. Though there may *also* be a problem with Kate I feel I cannot be sure so I'll file it under kdelibs.

Open Kate.

Open the Open dialog. Type ~/foo/ where foo does not exist as a directory (it may exist as a file or not) and press Enter. It gives an error:

---
The file file://foo/ could not be loaded, as it was not possible to read from it.
Check if you have read access to this file.
---

but in the backgruond I am able to see that the file foo has been added to the list of open documents on the left and the title bar shows file:///foo/

I close the error dialog and I am able to type in the file, though of course I am not allowed to save it with the following error:

---
The document could not be saved, as it was not possible to write to file://foo/.
Check that you have write access to this file or that enough disk space is available.
---

of course there is no because as normal user I do not have write access to the root directory (but later I found this is not a permissions problem).

But before closing this phantom file if I type Ctrl+O again, I get:

---
Could not connect to host for smb://foo/
---

with the open file dialog for some reason trying to access a samba share. (This is one reason I think this is a kdelibs bug, and not a kate bug.)

This thing (trying to access a samba share) does not occur after closing the phantom file with Ctrl+W.

Next I try entering foo/bar/spam/eggs/ where foo/bar/spam/eggs/ does not exist as directory. (Even foo may not exist -- I just enter this in the file dialog). The file eggs gets added to the list and the title bar shows file:///foo/bar/spam/eggs/ which again gives the following when I try to save it:

---
The document could not be saved, as it was not possible to write to file://foo/bar/spam/eggs/.
Check that you have write access to this file or that enough disk space is available.
---

and same kind of behaviour as before.

Later I tested the same things with kate running as superuser (using kdesu) and the behaviour was the same, so this is not really a problem of permissions. I think this is a problem of the open file dialog having returned an invalid path to the calling application and the application naively trusting the path as valid (since it came from KFileDialog which is supposed to take care of validation.)

I tried the same thing with KWrite but after getting the error saying "The file could not be loaded" the dialog box returned to the application. Same thing with Krita, KWord and friends. So there is some Kate-specificity to this bug.

But it's not entirely Kate-specific since I would expect the dialog to stick around till the user enters a valid file/path or aborts by pressing Cancel / Esc. What's more: I tried the same thing with Kolf -> "Open Saved Game" but I did not get any error. So maybe there is a problem with KFileDialog too.

The desired behaviour all around is just that:

When the user gives an invalid file/path, KFileDialog should report the error and stick around till either the user enters a valid file/path or aborts the dialog by pressing Cancel or Esc. It should not return, let alone return an invalid URL. This should be irrespective of the application calling.

P.S: Please tell me whether I should also file a bug under Kate.
Comment 1 Shriramana Sharma 2009-04-12 20:43:20 UTC
Hello I am the reporter of this bug. I confirm that this bug exists with KDE 4.2.2 on Kubuntu Hardy. Please confirm it and fix it. Thank you.
Comment 2 Christoph Feck 2009-08-27 02:37:32 UTC
Moving from "kio/kfile" component to "kfile" product, helps sorting out duplicates.
Comment 3 Nate Graham 2018-04-11 21:59:40 UTC
One issue per bug report please.

*** This bug has been marked as a duplicate of bug 317513 ***