[Pkg-bazaar-commits] ./bzr/unstable r535: - try to eliminate wierd characters from file names when they're
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:19:00 UTC 2009
------------------------------------------------------------
revno: 535
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-17 18:39:35 +1000
message:
- try to eliminate wierd characters from file names when they're
first added
modified:
bzrlib/branch.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-05-17 08:07:48 +0000
+++ b/bzrlib/branch.py 2005-05-17 08:39:35 +0000
@@ -785,6 +785,9 @@
This should probably generate proper UUIDs, but for the moment we
cope with just randomness because running uuidgen every time is
slow."""
+ import re
+
+ # get last component
idx = name.rfind('/')
if idx != -1:
name = name[idx+1 : ]
@@ -792,7 +795,12 @@
if idx != -1:
name = name[idx+1 : ]
+ # make it not a hidden file
name = name.lstrip('.')
+ # remove any wierd characters; we don't escape them but rather
+ # just pull them out
+ name = re.sub(r'[^\w.]', '', name)
+
s = hexlify(rand_bytes(8))
return '-'.join((name, compact_date(time.time()), s))
More information about the Pkg-bazaar-commits
mailing list