Escaping metafile paths

Gavin Carr gavin at openfusion.com.au
Thu Aug 6 05:43:32 UTC 2009


On Wed, Jul 29, 2009 at 09:45:44PM +1000, Gavin Carr wrote:
> As noted in the TODO, filenames with weird characters in them
> (especially noticeable with things like newlines and formfeeds)
> get written to the metafile verbatim, which can screw up the 
> metafile format and/or make brackup mis-detect the metafile as
> encrypted.
> 
> The attached patch escapes paths using String::Escape in
> Brackup::File, and unescapes them in Brackup::Restore, yielding
> paths like the following in the metafile:
> 
>   Path: filename\0cformfeed
>   Path: filename\rcarriage\rreturn
>   Path: filename whitespace
>   Path: filename_ctrl_c\03
>   Path: my_\0cdir
>   Path: my_\0cdir/sub_dir
>   Path: my_\0cdir/sub_dir/another-file.txt
>   Path: my_\0cdir/sub_dir/program.sh
> 
> Does this look reasonable to people? Any objections to adding
> a dependency on String::Escape?

I've committed this change. I also have a nice shiny unit test 
that includes data files like the above and does a backup / restore 
cycle, but I find I can't commit them to svn, which considers them 
invalid characters. :-( I'm using bzr, which handles them fine if
you upgrade to the latest repository format.

So the commit only has the code changes, not the unit test. Can't
see a way around that, unfortunately.

Cheers,
Gavin



More information about the brackup mailing list