Преглед изворни кода

Robustifying getCSRF agains improper encoding detection

Andrej пре 1 година
родитељ
комит
242ca22f72
1 измењених фајлова са 3 додато и 0 уклоњено
  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']))