GNOME Bugzilla – Bug 593372
save dialog treats trailing spaces literally
Last modified: 2015-07-04 23:22:32 UTC
Gnome allow adds trailing whitespaces after the filename (and the extension). For example you can rename the file 'name.ext' to be 'name.ext ' This happens when you save a file in any program too. Example: 1.- gedit foo.txt 2.- Edit the file and save 3.- Edit the file, and save as 'foo.txt ', now we have two files. Programs that expects a concrete filename will fail trying to open it. For example uncompress a rar archive with file-roller splitted in various parts. I'm not sure if this is bug or a feature, but anyway i think it isn't the behaviour that expects normal users. I know that it isn't a normal situation but can happen in a mistake. I find a bug a bit old that can be related to this http://bugzilla.gnome.org/show_bug.cgi?id=133806
This is not for GIO to deal with. Punting to GTK -- maybe the file save dialog should have code to say "are you sure you want to have a space at the end of the filename?" or maybe it should just silently drop it.
Federico: if you're adding 'gnome-love' keyword, do you have suggestions about what the correct behaviour should be?
We should extract the basename of the file (i.e. without directories) and ask the user if he has leading or trailing spaces. Dropping spaces silently is a no-no. This should only be done for the SAVE and CREATE_FOLDER modes, of course.
Might also want to ask about other 'bad' filename patterns, like names starting with one or more dots.
What about bash globbing characters (e.g. '[' ']' '*' '?' '^' ) or '!'? The user can, of course, put the filename in quotes to handle it in the shell, but to an ignorant user these rules can be frustrating.
I split the folder creation part of this to https://bugzilla.gnome.org/show_bug.cgi?id=751800 which has a patch pending.
Created attachment 306568 [details] [review] Strip leading and trailing whitespace from filechooser save filenames
Review of attachment 306568 [details] [review]: Looks ok. I've pushed it with a few cosmetic fixups.
Attachment 306568 [details] pushed as 94bcdd3 - Strip leading and trailing whitespace from filechooser save filenames