aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 6c7a80a..3e80089 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -59,9 +59,9 @@ except ImportError:
Reversible = object
try:
- from urllib.parse import quote, urlencode
+ from urllib.parse import quote, unquote, urlencode
except ImportError:
- from urllib import quote, urlencode
+ from urllib import quote, unquote, urlencode
try:
JSONDecodeError = json.JSONDecodeError
@@ -393,6 +393,15 @@ def format_exc_only():
return "".join(decode_from_utf8(traceback.format_exception_only(etype, value)))
+def url_encode_if_not_encoded(value):
+ decoded = unquote(value)
+ is_encoded = value != decoded
+ if is_encoded:
+ return value
+ else:
+ return quote(value)
+
+
def get_localvar_type(slack_type):
if slack_type in ("im", "mpim"):
return "private"
@@ -1478,7 +1487,10 @@ class SlackRequest(object):
def options(self):
cookies = "; ".join(
- ["{}={}".format(key, value) for key, value in self.cookies.items()]
+ [
+ "{}={}".format(key, url_encode_if_not_encoded(value))
+ for key, value in self.cookies.items()
+ ]
)
return {
"useragent": "wee_slack {}".format(SCRIPT_VERSION),