[#2784] [Execute] Escape ampersand in args for Windows
Due to the nature of passing a command and args to cmd.exe and then to a batch file in Windows any ampersands in execute args need to be double-escaped so prefixing with tripe-caret (^^^&) is the fix for this.
This commit is contained in:
parent
53215d87ee
commit
abf90f1dd6
|
@ -15,7 +15,7 @@ import time
|
||||||
from twisted.internet.utils import getProcessOutputAndValue
|
from twisted.internet.utils import getProcessOutputAndValue
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.common import utf8_encoded
|
from deluge.common import utf8_encoded, windows_check
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
from deluge.event import DelugeEvent
|
from deluge.event import DelugeEvent
|
||||||
|
@ -117,9 +117,15 @@ class Core(CorePluginBase):
|
||||||
if command[EXECUTE_EVENT] == event:
|
if command[EXECUTE_EVENT] == event:
|
||||||
command = os.path.expandvars(command[EXECUTE_COMMAND])
|
command = os.path.expandvars(command[EXECUTE_COMMAND])
|
||||||
command = os.path.expanduser(command)
|
command = os.path.expanduser(command)
|
||||||
|
|
||||||
|
cmd_args = [torrent_id, torrent_name, download_location]
|
||||||
|
if windows_check:
|
||||||
|
# Escape ampersand on windows (see #2784)
|
||||||
|
cmd_args = [cmd_arg.replace("&", "^^^&") for cmd_arg in cmd_args]
|
||||||
|
|
||||||
if os.path.isfile(command) and os.access(command, os.X_OK):
|
if os.path.isfile(command) and os.access(command, os.X_OK):
|
||||||
log.debug("Running %s", command)
|
log.debug("Running %s with args: %s", command, cmd_args)
|
||||||
d = getProcessOutputAndValue(command, (torrent_id, torrent_name, download_location), env=os.environ)
|
d = getProcessOutputAndValue(command, cmd_args, env=os.environ)
|
||||||
d.addCallback(log_error, command)
|
d.addCallback(log_error, command)
|
||||||
else:
|
else:
|
||||||
log.error("Execute script not found or not executable")
|
log.error("Execute script not found or not executable")
|
||||||
|
|
Loading…
Reference in New Issue