After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698892 - Error when dropping text with a slash (/)
Error when dropping text with a slash (/)
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: File and Folder Operations
3.8.x
Other Linux
: Normal minor
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-25 19:44 UTC by António Fernandes
Modified: 2013-07-29 17:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Replaces slashes with dashes in filenames (763 bytes, patch)
2013-07-22 18:09 UTC, William Kunkel
needs-work Details | Review
New patch with proper UTF8 string-walking (1.07 KB, patch)
2013-07-25 02:54 UTC, William Kunkel
committed Details | Review

Description António Fernandes 2013-04-25 19:44:10 UTC
Steps to reproduce:

Select text containing a slash ("/"). [Such as this very sentence.]
Drag the text selection and drop on a folder in nautilus.

     Actual result:

No file is created and this dialog pops up:

>     .     
>    / \    Error while creating file ").txt.
>   / ! \   
>  /_____\  There was an error creating the directory in /home/antonio.
>  
>           [-] Show more details
>           
>           Error opening file '/home/antonio/Select text containing a
>           slash ("/").txt': No such file or directory
>  
>                                                 [ Cancel ] [ Skip ]

     Expected result:

Text file is created with the dropped text. File name is created by replacing the slash with "-" or something.
Comment 1 William Kunkel 2013-07-22 18:09:46 UTC
Created attachment 249828 [details] [review]
Replaces slashes with dashes in filenames

I added a check for invalid characters in the final filename that fixes this issue.
Comment 2 Cosimo Cecchi 2013-07-23 01:09:27 UTC
Review of attachment 249828 [details] [review]:

::: src/nautilus-view-dnd.c
@@ +385,3 @@
 
+	/* Remove any invalid characters */
+	for (i = 0; ( i < g_utf8_strlen (filename, -1) ); i++) {

Two things here
* coding style: remove brackets around the i< check
* you're looping character by character, but accessing the offset into the string by byte. That is, filename[i] might not be the i-th character in the string if some character are larger than one byte. You should use something like g_utf8_next_char() to advance in the string and g_utf8_get_char() to get the character value
Comment 3 William Kunkel 2013-07-25 02:54:09 UTC
Created attachment 250088 [details] [review]
New patch with proper UTF8 string-walking
Comment 4 Cosimo Cecchi 2013-07-25 15:39:40 UTC
Review of attachment 250088 [details] [review]:

Looks good to me now, thanks!
Comment 5 Sindhu S 2013-07-26 12:37:26 UTC
Was this patch committed to master? I can't find it. I searched with https://git.gnome.org/browse/nautilus/log/?qt=author&q=William+Kunkel

and https://git.gnome.org/browse/nautilus/log/?qt=grep&q=Bug+698892
I was not able to find anything there.

Please commit the patch to master and close the bug if the patch has resolved the reported issue(s)?

Thank you.
Comment 6 Cosimo Cecchi 2013-07-26 14:47:28 UTC
It's not committed, otherwise the patch status would have read "committed", and the bug status RESOLVED FIXED...
Comment 7 William Kunkel 2013-07-26 20:27:31 UTC
Sorry, I've not really done this before. Do I need to do something to move this bug forward, or is it out of my hands now?
Comment 8 Sindhu S 2013-07-27 17:28:49 UTC
(In reply to comment #6)
Thanks, err isn't that obvious? Any particular reason that this has not been committed to master *yet*?

If you want me to, I can try this patch out, test it and commit to master and of course close the bug. Please confirm if you want me to do so. Thanks.
Comment 9 Cosimo Cecchi 2013-07-29 17:47:37 UTC
I just haven't had the time to push the patch previously :)
I now committed it to master, so this bug can be closed accordingly.