]> www.wagner.pp.ru Git - oss/ljdump.git/commitdiff
handle more potential non-filename characters in userpic keywords
authorGreg Hewgill <greg@hewgill.com>
Sat, 10 Jan 2009 01:46:51 +0000 (14:46 +1300)
committerGreg Hewgill <greg@hewgill.com>
Sat, 10 Jan 2009 01:46:51 +0000 (14:46 +1300)
ChangeLog
ljdump.py

index ba273d090557a3703e0cd1312a8466cb2f426e14..e89f69e47ab561ee4b0b31683e5907dd6594baf7 100644 (file)
--- 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
 
 - 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
 
 
 Version 1.3.2 - 2009-01-09
 
index 6a7e3a2655ff67d88814066c10332d17ef36c788..5b7a7a4fbdfe2221685c7710581267420ebb9d9d 100755 (executable)
--- a/ljdump.py
+++ b/ljdump.py
@@ -259,13 +259,13 @@ def ljdump(Server, Username, Password):
         print >>f, """<userpic keyword="%s" url="%s" />""" % (p, userpics[p])
         pic = urllib2.urlopen(userpics[p])
         ext = MimeExtensions.get(pic.info()["Content-Type"], "")
         print >>f, """<userpic keyword="%s" url="%s" />""" % (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
         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()
             picf = open("%s/%s%s" % (Username, picfn, ext), "wb")
         shutil.copyfileobj(pic, picf)
         pic.close()