Pārlūkot izejas kodu

Robustifying getCSRF agains improper encoding detection

Andrej 1 gadu atpakaļ
vecāks
revīzija
242ca22f72
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  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']))