From ce83ea497b648f3195a6a194e496dc9ba0292d7a Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 25 Aug 2020 13:10:23 +0200 Subject: #1001 Remove trailing \r and \n in some scripts We find that scripts sent by "Assistants"/"Asistentes" are losing the last character and scripts send by "Run Script"/"Ejecutar Script" have a trailing line feed (\n). This is happening because shell() function, which calls "/shell/run" of ogServer REST API, expects scripts send by "Asistentes" and "Run Script" to have two trailing characters and removes them. But "Assistants" only put one trailing char (\r) and "Run Script" put three trailing chars (\n\n\r). To avoid problems when running scripts without the last char or with trailing line feed this patch updates WebConsole to: 1) "Assistants" no longer put one trailing character at the end of the script 2) "Run Script" no longer puts three trailing characters at the end of the script 3) shell() expects no trailing chars in scripts sent by "Assistants" and "Run Script". --- admin/WebConsole/asistentes/jscripts/EjecutarScripts.js | 4 +--- admin/WebConsole/comandos/jscripts/EjecutarScripts.js | 4 +--- admin/WebConsole/includes/restfunctions.php | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/admin/WebConsole/asistentes/jscripts/EjecutarScripts.js b/admin/WebConsole/asistentes/jscripts/EjecutarScripts.js index 5452cf97..9b3d3b7c 100644 --- a/admin/WebConsole/asistentes/jscripts/EjecutarScripts.js +++ b/admin/WebConsole/asistentes/jscripts/EjecutarScripts.js @@ -12,9 +12,7 @@ // *********************************************************************************************************** function confirmar(){ if (comprobar_datos()){ - var RC='@'; - document.fdatosejecucion.atributos.value="scp="+escape(document.fdatos.codigo.value)+RC; - + document.fdatosejecucion.atributos.value="scp="+escape(document.fdatos.codigo.value); // Pedir confirmación si clonación masiva por Unicast. if (document.fdatosejecucion.ambito.value!=16 && document.fdatos.idmetodo !== undefined && (document.fdatos.idmetodo.value=="UNICAST" || document.fdatos.idmetodo.value=="UNICAST-DIRECT")) { diff --git a/admin/WebConsole/comandos/jscripts/EjecutarScripts.js b/admin/WebConsole/comandos/jscripts/EjecutarScripts.js index e97e6f2a..b03ee991 100644 --- a/admin/WebConsole/comandos/jscripts/EjecutarScripts.js +++ b/admin/WebConsole/comandos/jscripts/EjecutarScripts.js @@ -9,9 +9,7 @@ // *********************************************************************************************************** function confirmar(){ if (comprobar_datos()){ - var RC='@'; - document.fdatos.codigo.value+="\n"; - document.fdatosejecucion.atributos.value="scp="+escape(document.fdatos.codigo.value+"\n")+RC; + document.fdatosejecucion.atributos.value="scp="+escape(document.fdatos.codigo.value); filtrado(); // Incluimos el modo de ejecución en fdatosejecucion. var modoejecucion=document.createElement('input'); diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index ec4a323c..4067f697 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -144,9 +144,8 @@ function shell($case, $string_ips, $command) { break; case 3: $decoded_cmds = rawurldecode(substr($command, 4)); - $command = substr($decoded_cmds, 0, -2); $data = array(OG_REST_PARAM_CLIENTS => $ips, - OG_REST_PARAM_RUN => $command, + OG_REST_PARAM_RUN => $decoded_cmds, OG_REST_PARAM_ECHO => false); $command = OG_REST_CMD_RUN; break; -- cgit v1.2.3-18-g5258