From 8389ac7386d6b4ad386487d9645e6c21e9656d9a Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 21 Feb 2018 19:56:28 +0100 Subject: [PATCH] ncp-web: fix backend request without arguments --- ncp-web/ncp-launcher.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php index 318caa7af..7e905e7c5 100644 --- a/ncp-web/ncp-launcher.php +++ b/ncp-web/ncp-launcher.php @@ -84,15 +84,16 @@ $code = file_get_contents( $file ) or exit( '{ "output": "' . $file . ' read error" }' ); - foreach( $params as $name => $value) - { - preg_match( '/^[\w.,@_\/-]+$/' , $value , $matches ) - or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' ); - $code = preg_replace( '/\n' . $name . '_=.*' . PHP_EOL . '/' , - PHP_EOL . $name . '_=' . $value . PHP_EOL , - $code ) - or exit(); - } + if ( !empty( $params ) ) + foreach( $params as $name => $value ) + { + preg_match( '/^[\w.,@_\/-]+$/' , $value , $matches ) + or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' ); + $code = preg_replace( '/\n' . $name . '_=.*' . PHP_EOL . '/' , + PHP_EOL . $name . '_=' . $value . PHP_EOL , + $code ) + or exit(); + } file_put_contents($file, $code ) or exit( '{ "output": "' . $file . ' write error" }' );