Permalink
Browse files

Correct shell escaping of special characters

We need to escape special characters twice: once for the local execution of the
ssh command and once for the remote execution of the notifications script.

For instance, printing a single quote through an ssh connection requires:

    ssh localhost echo \\\'

Also include " (double quotes) in the list of special characters.
  • Loading branch information...
1 parent e477be3 commit caf60f89b63f66d0f5c37cdb22202c5425896792 @priteau priteau committed Jan 24, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 control/src/python/workspacecontrol/defaults/AsyncNotification.py
@@ -122,14 +122,13 @@ def _bashEscape(self, cmd):
"""returns \ escapes for some bash special characters"""
if not cmd:
return cmd
- escs = "\\'`|;()?#$^&*=[]<>"
+ escs = "\\\"'`|;()?#$^&*=[]<>"
for e in escs:
idx = 0
ret = 0
while ret != -1:
ret = cmd.find(e, idx)
if ret >= 0:
- cmd = "%s\%s" % (cmd[:ret],cmd[ret:])
- idx = ret + 2
+ cmd = "%s\\\\\\%s" % (cmd[:ret],cmd[ret:])
+ idx = ret + 4
return cmd
-

0 comments on commit caf60f8

Please sign in to comment.