Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions features/user-application-password.feature
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,30 @@ Feature: Manage user custom fields
"""
myapp
"""

@require-wp-5.6
Scenario: Backslashes in application password names are preserved
Given a WP install

When I run `wp user application-password create 1 'My\App\Test' --porcelain`
Then STDOUT should not be empty

When I run `wp user application-password list 1 --field=name`
Then STDOUT should be:
"""
My\App\Test
"""

When I run `wp user application-password list 1 --field=uuid`
And save STDOUT as {UUID}
And I run `wp user application-password update 1 {UUID} --name='New\App'`
Then STDOUT should contain:
"""
Success: Updated application password.
"""

When I run `wp user application-password get 1 {UUID} --field=name`
Then STDOUT should be:
"""
New\App
"""
4 changes: 2 additions & 2 deletions src/User_Application_Password_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function create( $args, $assoc_args ) {
'app_id' => $app_id,
];

$result = WP_Application_Passwords::create_new_application_password( (int) $user_id, $arguments );
$result = WP_Application_Passwords::create_new_application_password( (int) $user_id, wp_slash( $arguments ) );

if ( $result instanceof WP_Error ) {
WP_CLI::error( $result );
Expand Down Expand Up @@ -397,7 +397,7 @@ public function update( $args, $assoc_args ) {

list( $user_id, $uuid ) = $args;

$result = WP_Application_Passwords::update_application_password( $user_id, $uuid, $assoc_args );
$result = WP_Application_Passwords::update_application_password( $user_id, $uuid, wp_slash( $assoc_args ) );

if ( $result instanceof WP_Error ) {
WP_CLI::error( $result );
Expand Down