Ver código fonte

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

Joe 1 ano atrás
pai
commit
9ac1bbf3fb
1 arquivos alterados com 9 adições e 1 exclusões
  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