Skip to content

Commit 4ed325f

Browse files
authored
Escape URL parameter in update-db and check-update-db network commands (#338)
1 parent 82ec5d0 commit 4ed325f

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎features/core-check-update-db.feature‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,12 @@ Feature: Check if WordPress database update is needed
9898
Error: This is not a multisite installation.
9999
"""
100100
And the return code should be 1
101+
102+
Scenario: Check database update on network installation safely handles site domain/path with special characters
103+
Given a WP multisite install
104+
And I run `wp db query "INSERT INTO wp_blogs (site_id, domain, path, registered, last_updated) VALUES (1, 'example.com', '/x\\\$(touch /tmp/wpcli_test_check_db_marker)/', NOW(), NOW());"`
105+
106+
When I run `wp core check-update-db --network`
107+
Then the return code should be 0
108+
And the /tmp/wpcli_test_check_db_marker file should not exist
109+

‎src/Core_Command.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ public function check_update_db( $args, $assoc_args ) {
15101510
foreach ( $it as $blog ) {
15111511
++$total;
15121512
$url = $blog->domain . $blog->path;
1513-
$cmd = "--url={$url} core check-update-db";
1513+
$cmd = Utils\esc_cmd( '--url=%s core check-update-db', $url );
15141514

15151515
/**
15161516
* @var object{stdout: string, stderr: string, return_code: int} $process
@@ -1628,7 +1628,7 @@ public function update_db( $args, $assoc_args ) {
16281628
foreach ( $it as $blog ) {
16291629
++$total;
16301630
$url = $blog->domain . $blog->path;
1631-
$cmd = "--url={$url} core update-db";
1631+
$cmd = Utils\esc_cmd( '--url=%s core update-db', $url );
16321632
if ( $dry_run ) {
16331633
$cmd .= ' --dry-run';
16341634
}

0 commit comments

Comments
 (0)