Commit 6bf280c4 authored by Michal Čihař's avatar Michal Čihař

Catch TypeError as this is what gets raised

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 313c8f1c
...@@ -24,7 +24,6 @@ Simple mathematical captcha. ...@@ -24,7 +24,6 @@ Simple mathematical captcha.
from __future__ import unicode_literals from __future__ import unicode_literals
import ast import ast
import binascii
from base64 import b64encode, b64decode from base64 import b64encode, b64decode
import hashlib import hashlib
import operator import operator
...@@ -166,7 +165,7 @@ def unhash_question(question): ...@@ -166,7 +165,7 @@ def unhash_question(question):
timestamp = question[40:50] timestamp = question[40:50]
try: try:
question = b64decode(question[50:]).decode('utf-8') question = b64decode(question[50:]).decode('utf-8')
except (binascii.Error, UnicodeError): except (TypeError, UnicodeError):
raise ValueError('Invalid encoding') raise ValueError('Invalid encoding')
if hexsha != checksum_question(question, timestamp): if hexsha != checksum_question(question, timestamp):
raise ValueError('Tampered question!') raise ValueError('Tampered question!')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment