Sfoglia il codice sorgente

fix(slack-client): hack around cookie header bytes

Joe 1 anno fa
parent
commit
9ac1bbf3fb
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9 1
      .scripts/slack_client.py

+ 9 - 1
.scripts/slack_client.py

@@ -329,7 +329,15 @@ class CookiesParser(Cacheable):
             )
             with open(outfile, "rb") as f:
                 result = f.read()
-                result = result.decode("utf8")
+                # Rather then spend time understanding the format of the decrypted bytes
+                # (which does seem to vary), just throw out the first 8 bytes any time
+                # we don't get a valid ASCII string from decoding.
+                while True:
+                    try:
+                        result = result.decode("ascii")
+                        break
+                    except UnicodeDecodeError:
+                        result = result[8:]
                 self._write_cache(cache_key, result)
                 return result