aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-06-04 20:54:02 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-06-04 20:59:19 +0200
commit6b067faa304a296f60da46c6b67142ae0bfa0eeb (patch)
tree808bd491c7e26d14fb19993088159df859aa9772 /wee_slack.py
parent9e36b3b77f8dffde071427d54ebc357ccf1de4af (diff)
downloadwee-slack-6b067faa304a296f60da46c6b67142ae0bfa0eeb.tar.gz
Remove escape characters from path if file is not found
Some terminals (at least Terminal.app and iTerm2) escape spaces in the path when you drop a file in it. However, weechats tab completion does not escape them, so we can't just remove the escape characters, in case a user is trying to upload a file which has a name that contains "\ ". Therefore, first check if the file exists, and then remove escapes if it doesn't, and check if the unescaped name exists. Fixes #360
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 3419719..e29b463 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -4097,8 +4097,12 @@ def command_upload(data, current_buffer, args):
return w.WEECHAT_RC_ERROR
if not os.path.isfile(file_path):
- w.prnt('', 'ERROR: Could not find file: {}'.format(file_path))
- return w.WEECHAT_RC_ERROR
+ unescaped_file_path = file_path.replace(r'\ ', ' ')
+ if os.path.isfile(unescaped_file_path):
+ file_path = unescaped_file_path
+ else:
+ w.prnt('', 'ERROR: Could not find file: {}'.format(file_path))
+ return w.WEECHAT_RC_ERROR
post_data = {
'channels': channel.identifier,