Opened 7 years ago
Closed 6 years ago
#2784 closed bug (Fixed)
[Execute] Escape call parameters for Windows
Reported by: | Cas | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.3.14 |
Component: | Plugin | Version: | 1.3.12 |
Keywords: | Cc: |
Description
From: http://forum.deluge-torrent.org/viewtopic.php?f=9&t=48203&p=221405
To expand on my prior post, I'm talking about escaping required by the Windows OS command line. Unless an ampersand is escaped, Windows interprets it as separating 2 commands, so it runs everything before the ampersand as one command and everything after it as another command (ref: http://www.robvanderwoude.com/condexec.php). So when the execute plugin tries to run a command and the filename has an ampersand in it, Windows tries to run it as 2 separate and partial commands.
I have tested my script by calling it manually, and if it is called with the ampersand properly escaped, my script works fine. So the problem isn't my script as you suggested. And it's not an encoding issue. It's a Windows-specific command line escaping issue with the plugin.
Change History (4)
comment:1 Changed 7 years ago by Cas
comment:2 Changed 7 years ago by Cas
- Resolution set to Fixed
- Status changed from new to closed
Fixed the use-case for ampersand as other chars unlikely to be in torrent name (libtorrent fixes invalid chars on windows) or directories.
1.3-stable: [5f92810f761e7df7], develop: [abf90f1dd647a9b46]
comment:3 Changed 6 years ago by dashbad
- Resolution Fixed deleted
- Status changed from closed to reopened
I have come across this bug because my execute script is failing on Linux, because Ampersands are being escaped to &.
Steps to reproduce:
- Write bash script:
#!/bin/bash exec 1> >(logger -s -t $(basename $0)) 2>&1 export name="$1" echo $name
- Set script as execute script
- Trigger script for a torrent with an ampersand in the name
The syslog shows that the ampersand in the name has been converted to &
Can this change be rolled back/modified so it doesn't impact non-Windows users.
comment:4 Changed 6 years ago by Cas
- Milestone changed from 1.3.13 to 1.3.14
- Resolution set to Fixed
- Status changed from reopened to closed
This was fixed in 1.3.14: [df88c82265f7b]
So the answer here is to escape the ampersand with a tripe-caret e.g. ^^^& and then quote any echo output in the batch script. This requires more testing and a better understanding of how getProcessOutputAndValue works so leaving this one for now.
test.bat