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 424606 - Nautilus-scripts don't handle blanks in filenames properly
Nautilus-scripts don't handle blanks in filenames properly
Status: RESOLVED OBSOLETE
Product: nautilus
Classification: Core
Component: Scripts facilities
2.18.x
Other Linux
: Normal minor
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-03-30 19:41 UTC by Sebastien Bacher
Modified: 2021-06-18 15:13 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Sebastien Bacher 2007-03-30 19:41:07 UTC
The bug has been opened on https://launchpad.net/bugs/95519

"Binary package hint: nautilus

Nautilus-scripts don't handle blanks in filenames properly.

Reproduce the bug:
a) Create some files with blanks:

echo aaa > ~/tmp/foo\ bar
echo aaa > ~/tmp/bar\ foo

b) Create a script to operate on files:
# ---- start of script
files=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

for file in $files
do
 zenity --info --text "$(md5sum $file)"
done
# ---- end of script

Create that script in ~/.gnome2/nautilus-scripts.
Make it executable.
It will shine up in the context-menu of nautilus to run scripts.

It will execute fine, if you mark a few files, which don't contain a blank.
If there is a blank, it doesn't work.

To see how this is happening, create another script:
echo "---files---"
echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
echo "-----------"

You'll get something like:
    ---files---
    /home/stefan/tmp/foo bar /home/stefan/tmp/foo foo
    -----------

instead of:
    ---files---
    /home/stefan/tmp/foo bar
    /home/stefan/tmp/foo foo
    -----------

Suggestion: Use a different delimiter to split multiple marked files.
Use '\n' instead of ' '."
Comment 1 DougMcNutt 2009-11-27 00:03:15 UTC
A script in ubuntu 9.10

#!/bin/tcsh
set report = $HOME/expose.txt
echo  >> $report
date >> $report
echo "Arg1 is $1" >> $report
echo "Arg2 is $2" >> $report
echo "Arg3 is $3" >> $report
echo "NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" >> $report
echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS >> $report
echo "NAUTILUS_SCRIPT_SELECTED_URIS" >> $report
echo $NAUTILUS_SCRIPT_SELECTED_URIS >> $report
echo "NAUTILUS_SCRIPT_WINDOW_GEOMETRY" >> $report
echo "$NAUTILUS_SCRIPT_WINDOW_GEOMETRY" >> $report
echo "NAUTILUS_SCRIPT_CURRENT_URI" >> $report
echo "$NAUTILUS_SCRIPT_CURRENT_URI -- " >> $report


A directory listing with a file name with a space and a double space.
  Yeah, I don't do that but my friends, and my wife, do.

Mars[~/projects/nautilus]> ls -l
total 20
drwxr-xr-x 2 doug suntide 4096 2009-11-26 16:09 archived
-rw-r--r-- 1 doug suntide 3060 2008-05-09 11:32 expose_080509_113243.txt
-rw-r--r-- 1 doug suntide 2811 2009-10-26 09:28 exp os   e.txt
-rw-r--r-- 1 doug suntide 1726 2009-11-26 16:30 worksheet_nautilus
-rw-r--r-- 1 doug suntide  875 2009-11-26 16:10 worksheet_nautilus~

The results of running the above script:

Thu Nov 26 16:37:29 MST 2009
Arg1 is exp os   e.txt
Arg2 is expose_080509_113243.txt
Arg3 is worksheet_nautilus
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
/home/doug/projects/nautilus/exp os e.txt  /home/doug/projects/nautilus/expose_080509_113243.txt  /home/doug/projects/nautilus/worksheet_nautilus 
NAUTILUS_SCRIPT_SELECTED_URIS
file:///home/doug/projects/nautilus/exp%20os%20%20%20e.txt  file:///home/doug/projects/nautilus/expose_080509_113243.txt  file:///home/doug/projects/nautilus/worksheet_nautilus 
NAUTILUS_SCRIPT_WINDOW_GEOMETRY
712x686+1695+291
NAUTILUS_SCRIPT_CURRENT_URI
file:///home/doug/projects/nautilus -- 

Note that the URI is correct with URL encoded spaces.

Note that Arg1 is correct except that it requires quoting for most UNIX uses.

Note that the FILE_PATHS is hopelessly wrong. The triple space has been condensed to one space without warning and the double space between files would make a perl split command scream out loud if the first filename were to be correct.

Quoting file names with spaces would be better than nothing. Please take the time to move this to CONFIRMED status.
Comment 2 DougMcNutt 2009-11-27 00:08:39 UTC
Note that the results above have been word wrapped by the web site. The FILE_PATHS and URIS items are on one line with two spaces between each item as they exist in the environment variables.
Comment 3 André Klapper 2021-06-18 15:13:02 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version of Files (nautilus), then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/nautilus/-/issues/

Thank you for your understanding and your help.