Skip to content

Commit eef5fff

Browse files
Copilotswissspidy
andauthored
Fix: Apply wp_slash() to admin password in wp core install (#311)
* Initial plan * Fix: Apply wp_slash() to admin password in wp core install Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> * Apply suggestion from @swissspidy * PHPStan fix --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent 6e163fd commit eef5fff

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

features/core-install.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,22 @@ Feature: Install WordPress core
177177
"""
178178
And the return code should be 0
179179
180+
Scenario: Install WordPress with special characters in the admin password
181+
Given an empty directory
182+
And WP files
183+
And wp-config.php
184+
And a database
185+
186+
When I run `wp core install --url=localhost:8001 --title=Test --admin_user=wpcli --admin_email=wpcli@example.org --admin_password='R^^CzY;G"iZ@]H9b,' --skip-email`
187+
Then STDOUT should contain:
188+
"""
189+
Success: WordPress installed successfully.
190+
"""
191+
And the return code should be 0
192+
193+
When I run `wp user check-password wpcli 'R^^CzY;G"iZ@]H9b,' --escape-chars`
194+
Then the return code should be 0
195+
180196
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
181197
@require-mysql
182198
Scenario: Install WordPress with locale set to de_DE on WP >= 4.0

src/Core_Command.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,16 @@ function wp_new_blog_notification() {
704704
}
705705

706706
$public = true;
707-
$password = $args['admin_password'];
707+
$password = wp_slash( $args['admin_password'] );
708708

709709
if ( ! is_email( $args['admin_email'] ) ) {
710710
WP_CLI::error( "The '{$args['admin_email']}' email address is invalid." );
711711
}
712712

713+
/**
714+
* @var string $password
715+
*/
716+
713717
$result = wp_install(
714718
$args['title'],
715719
$args['admin_user'],

0 commit comments

Comments
 (0)