"bzr send" fails if branch nick contains a slash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Low
|
Unassigned |
Bug Description
I have a branch with a "/" in the nick (co-incidentally part of a loom). A "bzr send" with no further arguments fails:
$ bzr nick
Fix remote_
$ bzr send
Using saved location: /home/andrew/
bzr: ERROR: [Errno 2] No such file or directory: u'/tmp/
Full traceback:
$ bzr -Derror send
Using saved location: /home/andrew/
bzr: ERROR: exceptions.IOError: [Errno 2] No such file or directory: u'/tmp/
Traceback (most recent call last):
File "/home/
return run_bzr(argv)
File "/home/
ret = run(*run_argv)
File "/home/
return self.run(
File "/home/
kwargs.
File "/home/
outfile.
File "/home/
'x-patch', '.patch', basename)
File "/home/
outfile = open(attach_path, 'wb')
IOError: [Errno 2] No such file or directory: u'/tmp/
bzr 1.4dev on python 2.5.1 (linux2)
arguments: ['/home/
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_AU.UTF-8'
In general, we really need a try/except here, because sanitising perfectly and portably is almost impossible. Other than "/", I'd expect NUL bytes to cause issues, also "\", possibly unicode characters (not sure if the branch nick is unicode?), and also on platforms like windows special file names like "NUL:" and "PRN:" can cause trouble. And names like "." and ".." are special everywhere. So maybe the best strategy is to simply try the attach_path unmodified, and then if that throws an exception run a very aggressive sanitiser over the filename (perhaps the URL-escaping-like one we use for knit files?).
Changed in bzr: | |
importance: | Undecided → Low |
status: | New → Confirmed |
Changed in bzr: | |
status: | Confirmed → Fix Released |
I guess a less ambitious fix would be to catch the IOError, and simply use the regular temp file name generation (i.e. some random ascii letters and digits). It's not perfect, but it would be a big improvement over giving a traceback.