]> wagner.pp.ru Git - oss/ljdump.git/commitdiff
handle path separators in userpic keywords
authorGreg Hewgill <greg@hewgill.com>
Thu, 8 Jan 2009 18:28:50 +0000 (07:28 +1300)
committerGreg Hewgill <greg@hewgill.com>
Thu, 8 Jan 2009 18:29:09 +0000 (07:29 +1300)
ChangeLog
ljdump.py

index 32daf7f3d8edc1cc9d6e2a3fda7571b60df7402f..5cfd73d7e2a5118e545b0025686b3c8dd0e2451a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 ChangeLog - ljdump
 
+Version 1.3.2 - 2009-01-09
+
+- Bugfix: Handle case where userpic keywords contain a / or \.
+
 Version 1.3.1 - 2009-01-08
 
 - Feature: Download and save userpic images
index 0ab61ec5c79ba6a480479afbca76a245b66a3e24..d1e92874f7815e076548f24a8e93926bc9542f55 100755 (executable)
--- a/ljdump.py
+++ b/ljdump.py
@@ -284,12 +284,13 @@ for p in userpics:
     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)
     try:
-        picfn = codecs.utf_8_decode(p)[0]
+        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 p])
+        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()