add should refuse bad filenames

Bug #59968 reported by David R Dick
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned
Breezy
Triaged
Medium
Jelmer Vernooij

Bug Description

WHAT HAPPENED:
When a directory name that consisted of a single
control character (control-C was observed) was seen
by a 'bzr add' command, some subsequent commands
failed with an error in ElementTree().parse.

ANALYSIS:
I examined .bzr/checkout/inventory at a line referenced
in an error message and found a name element that looked like it contained '^C'. Upon examining the directory on the disk, I found a directory with a questionable, single-character name. Deleting it and starting clean with bzr got around the problem.

FIX:
Either the name should be canonicalized (encoded in
a safe form that all code which uses it knows about),
and/or a warning should be provided when the file/directory is first "bzr added".

Tags: add filenames
Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 59968] control char filename causes "parse error"

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David R Dick wrote:
> Public bug reported:
>
> WHAT HAPPENED:
> When a directory name that consisted of a single
> control character (control-C was observed) was seen
> by a 'bzr add' command, some subsequent commands
> failed with an error in ElementTree().parse.
>
> ANALYSIS:
> I examined .bzr/checkout/inventory at a line referenced
> in an error message and found a name element that looked like it contained '^C'. Upon examining the directory on the disk, I found a directory with a questionable, single-character name. Deleting it and starting clean with bzr got around the problem.
>
> FIX:
> Either the name should be canonicalized (encoded in
> a safe form that all code which uses it knows about),
> and/or a warning should be provided when the file/directory is first "bzr added".

This root cause of this problem is that we store this data in XML, and
XML1.0 doesn't permit most ASCII control codes.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFFBeM+0F+nu1YWqI0RAglDAJwMDlH93/nV1o6lTLIDd5UVXas4wACeK8r4
rJUJKZCajmqPVWezlx6JWLc=
=z+4k
-----END PGP SIGNATURE-----

Martin Pool (mbp)
Changed in bzr:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Fábio (machado2) wrote :

Now bzr.dev throws an exception when I add a file with an invalid filename, at mutabletree.py.
I didnt understand why its doing it, as the same line of code "for subf in sorted(os.listdir(abspath)):" worked for me in python command line.

bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 0: ordinal not in range(128)

Traceback (most recent call last):
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/commands.py", line 729, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/commands.py", line 691, in run_bzr
    ret = run(*run_argv)
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/commands.py", line 389, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/builtins.py", line 383, in run
    no_recurse, action=action, save=not dry_run)
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/mutabletree.py", line 50, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/fabio/repo/bazaar/bzr.dev/bzrlib/mutabletree.py", line 420, in smart_add
    for subf in sorted(os.listdir(abspath)):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 0: ordinal not in range(128)

bzr 0.19.0dev0 on python 2.5.1.final.0 (linux2)
arguments: ['/home/fabio/bin/bzrdev', 'add']

** please send this report to <email address hidden>

Jelmer Vernooij (jelmer)
tags: added: add
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Jelmer Vernooij (jelmer)
Changed in brz:
status: New → Triaged
importance: Undecided → Medium
tags: added: filenames
removed: check-for-breezy
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

FWIW newer versions of Bazaar/Breezy will happily add Ctrl+C characters.

We should probably raise an understandable exception though, on older platforms.

Changed in brz:
assignee: nobody → Jelmer Vernooij (jelmer)
milestone: none → 3.0.0
Jelmer Vernooij (jelmer)
Changed in brz:
milestone: 3.0.0 → 3.1.0
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.