Skip to content

Pass unslashed values to application password hooks - #148

Merged
peterwilsoncc merged 1 commit into
peterwilsoncc:fix/63927-doc-slashed-unslashedfrom
johnbillion:fix/63927-unslash-app-passwords
Nov 9, 2026
Merged

peterwilsoncc merged 1 commit into
peterwilsoncc:fix/63927-doc-slashed-unslashedfrom
johnbillion:fix/63927-unslash-app-passwords

Conversation

@johnbillion

Copy link
Copy Markdown

Stacked on top of WordPress#15608.

Instead of documenting that the application password hooks receive slashed values, this unslashes the input once, at the start of create_new_application_password() and update_application_password(). The wp_create_application_password and wp_update_application_password actions, the created notification email and its filters, and the returned details all receive unslashed values. The methods still expect slashed input, as before.

set_user_application_passwords() now slashes the passwords before saving, because the metadata API unslashes its input. This fixes two existing bugs:

  • Saving any application password stripped backslashes from the names of the user's other application passwords. This happened on create, update, usage recording and delete.
  • Updating an application password with its existing name returned a db_error when the name contained a quote or backslash.

The trade-off: an existing callback that already calls wp_unslash() on these values will strip backslashes that a user actually typed. Quotes are unaffected. Backslashes in application password names should be rare, whereas callbacks that don't unslash currently show apostrophes as John\'s laptop.

Trac ticket: https://core.trac.wordpress.org/ticket/63927

Testing

New tests in tests/phpunit/tests/rest-api/application-passwords.php cover the hook arguments, return values and stored values, updates with an unchanged name, and backslashes surviving later saves. The application password, REST controller, connector, auth and notification tests pass on single-site and multisite.

`create_new_application_password()` and `update_application_password()` now unslash their input, so the `wp_create_application_password` and `wp_update_application_password` actions, the created notification email, and the returned details all receive unslashed values.

`set_user_application_passwords()` now slashes the passwords before saving them, because the metadata API unslashes its input. Previously, saving any application password stripped backslashes from the names of the user's other application passwords, and updating an application password with its existing name returned an error when the name contained a quote or backslash.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props johnbillion.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@johnbillion

Copy link
Copy Markdown
Author

For some reason I can't request a review from you @peterwilsoncc

@peterwilsoncc
peterwilsoncc self-requested a review November 9, 2026 21:07
@peterwilsoncc
peterwilsoncc merged commit 05c1619 into peterwilsoncc:fix/63927-doc-slashed-unslashed Nov 9, 2026
4 checks passed
@peterwilsoncc

Copy link
Copy Markdown
Owner

@johnbillion I've merged this in to my PR. Thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants