# HG changeset patch # User Edho Prima Arief # Date 1310580678 -25200 # Node ID 9be628347dce63d9efdf673d1733ea827c0516aa # Parent 65ce115fd21d15c80d7f29cf8beff44cbff4383e Worst thing about unix: it allows control character and newline in its filename. Added handler to ensure that shit doesn't pass through. Makes things slow but it can't be helped (tm). diff -r 65ce115fd21d -r 9be628347dce bin/recompress --- a/bin/recompress Thu Jul 14 00:51:44 2011 +0700 +++ b/bin/recompress Thu Jul 14 01:11:18 2011 +0700 @@ -21,9 +21,13 @@ current_unit += 1 return "%.2f %s" % (outbyte, units[current_unit]) +def sane_fn(filename): + import re + return re.sub(r"[\x00-\x1F\x7F\n\r]", "?", filename) + if __name__ == "__main__": for filename in sys.argv[1:]: - print "Recompressing %s:" % filename, + print "Recompressing %s:" % sane_fn(filename), sys.stdout.flush() try: byte_orig = os.path.getsize(filename)