Explorar o código

Robustifying getCSRF agains improper encoding detection

Andrej hai 1 ano
pai
achega
242ca22f72
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      labkeyInterface.py

+ 3 - 0
labkeyInterface.py

@@ -146,6 +146,9 @@ class labkeyInterface:
         except AttributeError:
             print('Failed')
             return None
+        except chardet.UnicodeDecodeError:
+            encoding='ASCII'
+            jsonData=json.loads(response.data.decode(encoding))
 
         self.cookie=response.getheader('Set-Cookie')
         print('User: {} CSRF: {}'.format(jsonData['displayName'],jsonData['CSRF']))