check if hash is a base-16 string
This commit is contained in:
parent
e244227f41
commit
82da63a81b
@ -170,7 +170,7 @@ class API(object):
|
|||||||
max_age=self.conf.getint('max-age'))
|
max_age=self.conf.getint('max-age'))
|
||||||
|
|
||||||
rv["text"] = markdown(rv["text"])
|
rv["text"] = markdown(rv["text"])
|
||||||
rv["hash"] = str(pbkdf2(rv['email'] or rv['remote_addr'], self.isso.salt, 1000, 6))
|
rv["hash"] = pbkdf2(rv['email'] or rv['remote_addr'], self.isso.salt, 1000, 6).decode("utf-8")
|
||||||
|
|
||||||
self.cache.set('hash', (rv['email'] or rv['remote_addr']).encode('utf-8'), rv['hash'])
|
self.cache.set('hash', (rv['email'] or rv['remote_addr']).encode('utf-8'), rv['hash'])
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class API(object):
|
|||||||
val = self.cache.get('hash', key.encode('utf-8'))
|
val = self.cache.get('hash', key.encode('utf-8'))
|
||||||
|
|
||||||
if val is None:
|
if val is None:
|
||||||
val = str(pbkdf2(key, self.isso.salt, 1000, 6))
|
val = pbkdf2(key, self.isso.salt, 1000, 6).decode("utf-8")
|
||||||
self.cache.set('hash', key.encode('utf-8'), val)
|
self.cache.set('hash', key.encode('utf-8'), val)
|
||||||
|
|
||||||
item['hash'] = val
|
item['hash'] = val
|
||||||
|
@ -219,6 +219,7 @@ class TestComments(unittest.TestCase):
|
|||||||
b = loads(b.data)
|
b = loads(b.data)
|
||||||
c = loads(c.data)
|
c = loads(c.data)
|
||||||
|
|
||||||
|
assert isinstance(int(a['hash'], 16), int)
|
||||||
assert a['hash'] != '192.168.1.1'
|
assert a['hash'] != '192.168.1.1'
|
||||||
assert a['hash'] == b['hash']
|
assert a['hash'] == b['hash']
|
||||||
assert a['hash'] != c['hash']
|
assert a['hash'] != c['hash']
|
||||||
|
Loading…
Reference in New Issue
Block a user