aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2015-02-28 22:29:30 +0100
committerpiernov <piernov@piernov.org>2015-02-28 22:29:30 +0100
commit9ce9174d981803ddca90f4bdb57b981598721a98 (patch)
treed6b31e7d021f549b9cb04494faf5bf3d045499ce
parent7402e7b87325aeb694fca5a357a066357643166c (diff)
downloadjm2l-9ce9174d981803ddca90f4bdb57b981598721a98.tar.gz
jm2l-9ce9174d981803ddca90f4bdb57b981598721a98.tar.bz2
jm2l-9ce9174d981803ddca90f4bdb57b981598721a98.tar.xz
jm2l-9ce9174d981803ddca90f4bdb57b981598721a98.zip
Add some explicit string utf-8 encoding/decoding
-rw-r--r--jm2l/models.py12
-rw-r--r--jm2l/upload.py2
2 files changed, 7 insertions, 7 deletions
diff --git a/jm2l/models.py b/jm2l/models.py
index 0bc212c..54acdf3 100644
--- a/jm2l/models.py
+++ b/jm2l/models.py
@@ -161,14 +161,14 @@ class User(Base):
@property
def my_hash(self):
m = hashlib.sha1()
- m.update("Nobody inspects ")
+ m.update("Nobody inspects ".encode('utf-8'))
if self.nom:
- m.update(unicode.encode(self.nom,'utf8'))
+ m.update(self.nom.encode('utf-8'))
if self.pseudo:
- m.update(unicode.encode(self.pseudo,'utf8'))
- if self.prenom:
- m.update(unicode.encode(self.prenom,'utf8'))
- m.update(" the spammish repetition")
+ m.update(self.pseudo.encode('utf-8'))
+ if self.prenom:
+ m.update(self.prenom.encode('utf-8'))
+ m.update(" the spammish repetition".encode('utf-8'))
return m.hexdigest()
@property
diff --git a/jm2l/upload.py b/jm2l/upload.py
index 22281b8..551eb27 100644
--- a/jm2l/upload.py
+++ b/jm2l/upload.py
@@ -134,7 +134,7 @@ class MediaUpload(MediaPath):
def validate(self, result, filecontent):
# let's say we don't trust the uploader
- RealMime = magic.from_buffer( filecontent.read(1024), mime=True)
+ RealMime = magic.from_buffer( filecontent.read(1024), mime=True).decode('utf-8')
filecontent.seek(0)
if RealMime!=result['type']:
result['error'] = 'l\'extension du fichier ne correspond pas à son contenu - '