sftp cannot get filenames with "[" and "]" whith space between

Bug #267980 reported by Spayder26
2
Affects Status Importance Assigned to Milestone
openssh (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

sftp cannot get a filename named "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano] [By.Tetsu].avi", but when I renamed to "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano", it can.

sftp shows error when file with filename has "[" "]" character (with a space or more between):
File [...] not found.

But sftp's remote renaming, moving, and more still working.

Commands used:
$: sftp user@192.168.1.35
sftp> get "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano] [By.Tetsu].avi"
File "/home/user/South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano] [By.Tetsu].avi" not found.
sftp> rename "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano] [By.Tetsu].avi" "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano"
sftp> get "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano"
(And works!)

Note: Renaming to "South Park - 10x08 - Make Love, Not Warcraft [ Subtitulado.al.Castellano_ [By.Tetsu_.avi" works too.

EDITED:
very confusing:
I've renamed some files for testing and...
sftp> get "selene ]"
Fetching /home/mluser/selene ] to selene ]
/home/mluser/selene ] 100% 53 0.1KB/s 00:00
sftp> get "selene [ ]"
File "/home/mluser/selene [ ]" not found.
sftp> ls -1
incoming
selene , . [ ]
selene , [ ]
selene [
selene [ ]
selene ]
selene[
selene[]
selene]
selenedb
share.tar.gz

so "selene [ ]" exists!

Spayder26 (spayder26)
description: updated
Spayder26 (spayder26)
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Spayder26 (spayder26) wrote : Re: sftp cannot get filenames with "[ " and " ]"

and getting "selene[]" (whithout spaces) works too.
sftp> get "selene[]"
Fetching /home/mluser/selene[] to selene[]
/home/mluser/selene[] 100% 53 0.1KB/s 00:00

description: updated
description: updated
Revision history for this message
jjos (jbenjos) wrote :

Hello Spayder26,

What version of Ubuntu are you running? Also can you try substituting [ for \] and seeing if it works like that?

-Jonathan

Spayder26 (spayder26)
description: updated
Revision history for this message
Spayder26 (spayder26) wrote :

I've updated description so get "selene []" works, but get "selene[ ]" and "selene[_ ]" don't.

Jonathan, I'm using Ubuntu hardy amd64 as client, and i386 as server, linux 2.6.24-19, and openssh-client and server version 1:4.9p1-8ubuntu1.2.

sftp> ls
incoming selene , . [ ] selene , [ ] selene [ selene [ ] selene [] selene ] selene[ selene[ ] selene[ _] selene[]
selene[_ ] selene] selene][ _ selenedb share.tar.gz
sftp> get "selene[_ ]"
File "/home/mluser/selene[_ ]" not found.
sftp> get "selene[_ \]"
Bad escaped character '\\]'

As you see, using \ throws error.

Revision history for this message
Colin Watson (cjwatson) wrote :

You probably need to substitute both [ and ], e.g.:

  get "selene\[_ \]"

(I suspect OpenSSH 5.1p1 in Intrepid has more sensible handling here, although I haven't tested it; there was certainly a comment in the upstream release notes about all this having been cleaned up.)

Revision history for this message
Spayder26 (spayder26) wrote :

sftp> get "selene \[ \]"
Bad escaped character '\\['

Doesn't.

Can someone test this issue?

Revision history for this message
Spayder26 (spayder26) wrote :

Sorry for my misspellings, I'm not very fine yesterday and today at morning hehe.

Revision history for this message
Spayder26 (spayder26) wrote :

Can anybody reproduce the issue?

Revision history for this message
Caspar Clemens Mierau (leitmedium) wrote :

Thanks for taking the time to report this problem. It is actually not a bug but rather normal behaviour. The trouble you are in is that special characters need to be "escaped". This are not only brackets, but also white spaces like " ". So, if you want to transfer a file try this:

file name "test[ ].txt"
$ scp SERVER:test\\\[\\\ \\\].txt DESTINATION

If you want a comformatable way, try installing a shell like "zsh" and configure auto completion as this enables you to handle this in a very comfortable way. Feel free to ask in Launchpad Answers for this.

Best.

Changed in openssh:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.