diff options
author | dgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2007-01-28 02:49:01 +0000 |
---|---|---|
committer | dgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2007-01-28 02:49:01 +0000 |
commit | 4b91bec34dfa3c5d6b2ecdcf26faedb19efb1cd5 (patch) | |
tree | 8940bb6f8f6152ac3f966ad614d54479cef5a34b /rdiff-backup/rdiff_backup | |
parent | 669caac18494ed7233dfb3c1439ab5608b2a074b (diff) | |
download | rdiff-backup-4b91bec34dfa3c5d6b2ecdcf26faedb19efb1cd5.tar.gz |
Escape DOS device filenames when necessary. [Marc Dyksterhouse]
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@779 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r-- | rdiff-backup/rdiff_backup/FilenameMapping.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/rdiff-backup/rdiff_backup/FilenameMapping.py b/rdiff-backup/rdiff_backup/FilenameMapping.py index b730fd3..cecf76c 100644 --- a/rdiff-backup/rdiff_backup/FilenameMapping.py +++ b/rdiff-backup/rdiff_backup/FilenameMapping.py @@ -83,7 +83,17 @@ def quote(path): the quoting character. """ - return chars_to_quote_regexp.sub(quote_single, path) + QuotedPath = chars_to_quote_regexp.sub(quote_single, path) + if not Globals.must_escape_dos_devices: + return QuotedPath + + # Escape first char of any special DOS device files even if filename has an + # extension. Special names are: aux, prn, con, nul, com0-9, and lpt1-2. + if not re.search(r"^aux(\..*)*$|^prn(\..*)*$|^con(\..*)*$|^nul(\..*)*$|" \ + r"^com[0-9](\..*)*$|^lpt[12]{1}(\..*)*$", QuotedPath, \ + re.I): + return QuotedPath + return "%s%03d" % (quoting_char, ord(QuotedPath[0])) + QuotedPath[1:] def quote_single(match): """Return replacement for a single character""" |