Skip to content

Commit

Permalink
P511 escaping command strings if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
enesbcs committed Aug 22, 2021
1 parent 6546f72 commit 04023e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions _P511_RunOSCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import commands
import threading
import Settings
import urllib

class Plugin(plugin.PluginProto):
PLUGIN_ID = 511
Expand Down Expand Up @@ -50,8 +51,14 @@ def plugin_init(self,enableplugin=None):
self.timer100ms = True

def webform_load(self):
webserver.addFormTextBox("Command 0","plugin_511_cmd0",str(self.taskdevicepluginconfig[0]),512)
webserver.addFormTextBox("Command 1","plugin_511_cmd1",str(self.taskdevicepluginconfig[1]),512)
cmd1 = str(self.taskdevicepluginconfig[0])
if '"' in cmd1 or "'" in cmd1:
cmd1 = urllib.parse.quote(cmd1)
cmd2 = str(self.taskdevicepluginconfig[1])
if '"' in cmd2 or "'" in cmd2:
cmd2 = urllib.parse.quote(cmd2)
webserver.addFormTextBox("Command 0","plugin_511_cmd0",cmd1,512)
webserver.addFormTextBox("Command 1","plugin_511_cmd1",cmd2,512)
webserver.addFormNote("Specify OS commands that has to be executed at the speficied state (0/1)")
webserver.addFormCheckBox("Use threading to run in background","plugin_511_th",self.taskdevicepluginconfig[2])
webserver.addFormCheckBox("Enable parsing command line before execute","plugin_511_parse",self.taskdevicepluginconfig[3])
Expand All @@ -74,8 +81,8 @@ def webform_load(self):
return True

def webform_save(self,params):
self.taskdevicepluginconfig[0] = str(webserver.arg("plugin_511_cmd0",params)).strip()
self.taskdevicepluginconfig[1] = str(webserver.arg("plugin_511_cmd1",params)).strip()
self.taskdevicepluginconfig[0] = urllib.parse.unquote(str(webserver.arg("plugin_511_cmd0",params)).strip())
self.taskdevicepluginconfig[1] = urllib.parse.unquote(str(webserver.arg("plugin_511_cmd1",params)).strip())
if str(self.taskdevicepluginconfig[0])=="0":
self.taskdevicepluginconfig[0]=""
if str(self.taskdevicepluginconfig[1])=="0":
Expand Down Expand Up @@ -116,6 +123,7 @@ def runcmd(self,number): # run command stored at taskdevicepluginconfig[number]
cmdline = str(cl)
else:
cmdline = str(cmdline)
# print("XXX ",cmdline," XXX")#debug
output = os.popen(cmdline)
if self.taskdevicepluginconfig[2]:
return True
Expand Down
2 changes: 1 addition & 1 deletion rpieGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright (C) 2018-2020 by Alexander Nagy - https://bitekmindenhol.blog.hu/
#
PROGNAME = "RPIEasy"
BUILD = 21218
BUILD = 21234
PROGVER = str(BUILD)[:1]+"."+str(BUILD)[1:2]+"."+str(BUILD)[2:]

gpMenu = []
Expand Down

0 comments on commit 04023e5

Please sign in to comment.