Skip to content

Commit 1d6e796

Browse files
committed
Correct validation
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
1 parent 1a2b455 commit 1d6e796

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/Cron_Command.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function add( $args, $assoc_args ) {
8989
}
9090
}
9191

92-
$this->semi_colon_check( $command );
92+
$this->validate_command( $command );
9393
$command = $this->add_sh_c_wrapper( $command );
9494

9595
EE::db()->insert(
@@ -171,7 +171,7 @@ public function update( $args, $assoc_args ) {
171171
$data_to_update['sitename'] = $site;
172172
}
173173
if ( $command ) {
174-
$this->semi_colon_check( $command );
174+
$this->validate_command( $command );
175175
$command = $this->add_sh_c_wrapper( $command );
176176
$data_to_update['command'] = $command;
177177
}
@@ -332,12 +332,18 @@ private function site_php_container( $site ) {
332332
return str_replace( '.', '', $site ) . '_php_1';
333333
}
334334

335-
private function semi_colon_check( $command ) {
336-
// Semicolons in commands do not work for now due to limitation of INI style config ofelia uses
335+
/**
336+
* Ensures given command will not create problem with INI syntax
337+
*/
338+
private function validate_command( $command ) {
339+
// Semicolons and Hash(#) in commands do not work for now due to limitation of INI style config ofelia uses
337340
// See https://github.com/EasyEngine/cron-command/issues/4
338341
if ( strpos( $command, ';' ) !== false ) {
339342
EE::error( 'Command chaining using `;` - semi-colon is not supported currently. You can either use `&&` or `||` or creating a second cron job for the chained command.' );
340343
}
344+
if ( strpos( $command, '#' ) !== false ) {
345+
EE::error( 'EasyEngine does not support commands with #' );
346+
}
341347
}
342348

343349
private function add_sh_c_wrapper( $command ) {

0 commit comments

Comments
 (0)