From 245a811657855e2b846068dccdbbb83ced2c249e Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Sat, 10 Jan 2009 14:46:51 +1300 Subject: [PATCH] handle more potential non-filename characters in userpic keywords --- ChangeLog | 1 + ljdump.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba273d0..e89f69e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Version 1.3.3 - 2009-01-10 - Feature: ljdump now prompts for login info if ljdump.config does not exist - Bugfix: Automatically handle UnicodeDecodeError for old entries +- Bugfix: Handle more non-filename characters of userpic keywords Version 1.3.2 - 2009-01-09 diff --git a/ljdump.py b/ljdump.py index 6a7e3a2..5b7a7a4 100755 --- a/ljdump.py +++ b/ljdump.py @@ -259,13 +259,13 @@ def ljdump(Server, Username, Password): print >>f, """""" % (p, userpics[p]) pic = urllib2.urlopen(userpics[p]) ext = MimeExtensions.get(pic.info()["Content-Type"], "") - picfn = re.sub(r"[\/]", "_", p) + picfn = re.sub(r'[*?\\/:<>"|]', "_", p) try: picfn = codecs.utf_8_decode(picfn)[0] picf = open("%s/%s%s" % (Username, picfn, ext), "wb") except: # for installations where the above utf_8_decode doesn't work - picfn = "".join([ord(x) < 128 and x or "?" for x in picfn]) + picfn = "".join([ord(x) < 128 and x or "_" for x in picfn]) picf = open("%s/%s%s" % (Username, picfn, ext), "wb") shutil.copyfileobj(pic, picf) pic.close() -- 2.39.2