Skip to content

Commit

Permalink
ncp-web: fix backend request without arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Feb 21, 2018
1 parent 8d100b9 commit 8389ac7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ncp-web/ncp-launcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" }' );
Expand Down

0 comments on commit 8389ac7

Please sign in to comment.