csvimport: Return error if input is not valid UTF-8

pull/380/head
Jakub Onderka 2020-03-12 11:02:43 +01:00 committed by GitHub
parent 0e84ea7ad3
commit fe34023866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -256,7 +256,11 @@ def handler(q=False):
return False
request = json.loads(q)
if request.get('data'):
data = base64.b64decode(request['data']).decode('utf-8')
try:
data = base64.b64decode(request['data']).decode('utf-8')
except UnicodeDecodeError:
misperrors['error'] = "Input is not valid UTF-8"
return misperrors
else:
misperrors['error'] = "Unsupported attributes type"
return misperrors