Skip to content

Commit

Permalink
Avoid escaping an existing "extra-php" value
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Jan 6, 2022
1 parent fba0e57 commit 44abadc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Config_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,23 @@ public function create( $_, $assoc_args ) {
$assoc_args['add-wplang'] = false;
}

$assoc_args = array_map( [ $this, 'escape_config_value' ], $assoc_args );
// Store 'extra-php' and reinsert later, it mustn't be escaped.
if ( array_key_exists( 'extra-php', $assoc_args ) ) {
$unescaped_extra_php = $assoc_args['extra-php'];
unset( $assoc_args['extra-php'] );
}

$assoc_args = array_map(
[ $this, 'escape_config_value' ],
$assoc_args
);

if ( isset( $unescaped_extra_php ) ) {
$assoc_args['extra-php'] = $unescaped_extra_php;
}

// 'extra-php' is retrieved after escaping to avoid breaking the PHP code.
// 'extra-php' from STDIN is retrieved after escaping to avoid breaking
// the PHP code.
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
$assoc_args['extra-php'] = file_get_contents( 'php://stdin' );
}
Expand Down

0 comments on commit 44abadc

Please sign in to comment.