Skip to content

Commit 6fc315e

Browse files
authored
Merge pull request #264 from WordPress/fix/excessive-escaping
Avoid excessive escaping when an SSH connection is configured
2 parents 5e35b46 + 7f5365d commit 6fc315e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

report.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* safely used in shell commands.
5050
*/
5151
log_message('Copying junit.xml results');
52-
$junit_location = escapeshellarg( $runner_vars['WPT_TEST_DIR'] ) . '/tests/phpunit/build/logs/*';
52+
$junit_location = $runner_vars['WPT_TEST_DIR'] . '/tests/phpunit/build/logs/*';
5353

5454
/**
5555
* Modifies the junit.xml results file path for a remote location if an SSH connection is available.
@@ -58,8 +58,8 @@
5858
* command and options for accessing the remote file system. It concatenates SSH options with the
5959
* remote path to ensure that the junit.xml results can be accessed or copied over SSH.
6060
*/
61-
if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) {
62-
$junit_location = '-e "ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . '" ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] . ':' . $junit_location );
61+
if ( ! empty( $WPT_SSH_CONNECT ) ) {
62+
$junit_location = '-e "ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . '" ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ':' . escapeshellarg( $junit_location );
6363
}
6464

6565
/**

test.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@
6565
* avoid reporting useless tests.
6666
*/
6767
$WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) );
68-
if( empty( $WPT_PHPUNIT_CMD ) ) {
69-
$WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $runner_vars['WPT_TEST_DIR'] ) . ' && ' . $runner_vars['WPT_PHP_EXECUTABLE'] . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT;
68+
if ( empty( $WPT_PHPUNIT_CMD ) ) {
69+
$WPT_PHPUNIT_CMD = escapeshellarg( 'cd ' . $runner_vars['WPT_TEST_DIR'] ) . ' && ' . $runner_vars['WPT_PHP_EXECUTABLE'] . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT );
70+
} else {
71+
$WPT_PHPUNIT_CMD = escapeshellarg( $WPT_PHPUNIT_CMD );
7072
}
7173

7274
// If an SSH connection string is provided, prepend the SSH command to the PHPUnit execution command.
7375
if ( ! empty( $runner_vars['WPT_SSH_CONNECT'] ) ) {
74-
$WPT_PHPUNIT_CMD = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . escapeshellarg( $WPT_PHPUNIT_CMD );
76+
$WPT_PHPUNIT_CMD = 'ssh ' . $runner_vars['WPT_SSH_OPTIONS'] . ' ' . escapeshellarg( $runner_vars['WPT_SSH_CONNECT'] ) . ' ' . $WPT_PHPUNIT_CMD;
7577
}
7678

7779
// Execute the PHPUnit command.

0 commit comments

Comments
 (0)