Commit db9055aa authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

html.escape and request format

parent a508f5b2
...@@ -20,15 +20,17 @@ def parse_command(string): ...@@ -20,15 +20,17 @@ def parse_command(string):
e = ET.fromstring(string) e = ET.fromstring(string)
tmp = e.find('cmd') tmp = e.find('cmd')
if tmp!=None: if tmp!=None and tmp.text!=None:
# have to escape: & # have to escape: &
msg['cmd'] = html.escape(tmp.text) msg['cmd'] = html.escape(tmp.text)
else: else:
msg['cmd'] = 'state' msg['cmd'] = 'state'
tmp = e.findall('target') tmp = e.find('targets')
if not tmp: if tmp!=None and tmp.text!=None:
msg['targets'] = tmp.text.split(",")
else:
msg['targets'] = clients msg['targets'] = clients
return msg return msg
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import subprocess import subprocess
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import html
import rclpy import rclpy
from elphel_interfaces.srv import StrReqStrRes from elphel_interfaces.srv import StrReqStrRes
...@@ -40,7 +41,7 @@ def cmd_callback(req,res): ...@@ -40,7 +41,7 @@ def cmd_callback(req,res):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
output = "<error>CalledProcessError</error>".encode() output = "<error>CalledProcessError</error>".encode()
res.response = '<state>'+output.decode()+'</state>' res.response = '<state>'+html.escape(output.decode())+'</state>'
print('Slave sending: '+res.response) print('Slave sending: '+res.response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment