Escape remaining wp_options LIKE patterns with esc_like() (parity follow-up to #462)#467
Merged
Merged
Conversation
Two legacy code paths built wp_options LIKE patterns from a taxonomy (and term) and escaped only the `_` wildcard via str_replace(), leaving `%` and `\` active — the same class as #462: - acf_form_taxonomy::delete_term() (legacy no-termmeta DELETE) - acf_upgrade_550_taxonomy() (one-time admin upgrade SELECT) Both are fed trusted input today (a core delete_term hook's integer term id / a registered taxonomy name), so neither is reachable with hostile wildcard bytes; this is parity hardening to the WordPress-standard $wpdb->esc_like(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Captures the SQL each path generates (via the dbless wpdb query filter, since the query is a no-op under WorDBless) and asserts the dynamic part is escaped through esc_like(). Confirmed to fail against the pre-fix code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This was referenced Jun 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #462. A scoping pass found two more legacy code paths that build
wp_optionsLIKEpatterns and escape only the_wildcard viastr_replace( '_', '\_', … ), leaving%and the\escape character active — the same pattern that #462 fixed:includes/forms/form-taxonomy.php—acf_form_taxonomy::delete_term()(aDELETE … WHERE option_name LIKE), on the legacy pre-termmeta path.includes/upgrades.php—acf_upgrade_550_taxonomy()(a one-time adminSELECT … LIKE).Both migrate to
$wpdb->esc_like(), which escapes%,_and\.Reachability
Neither is reachable with hostile wildcard bytes today:
delete_term()'s$termis the integer term id passed by core'sdelete_termaction and$taxonomyis a registered taxonomy name;acf_upgrade_550_taxonomy()runs only during an admin-triggered one-time DB upgrade with a registered taxonomy name. This is parity hardening so the whole codebase uses the correct primitive — not a fix for a live, untrusted-input-reachable issue.Tests
Adds
tests/php/includes/test-like-escaping-parity.php, which captures the SQL each path generates (the queries are no-ops under WorDBless) and asserts the dynamic part is escaped throughesc_like(). Both tests were confirmed to fail against the pre-fix code.composer test:php: OK (2825 tests).composer test:phpstan: clean.phpcs(changed lines): clean.Note
These files are derived from upstream; the same change applies there.
Use of AI Tools
Authored by Claude Code (Claude Fable 5) under human direction.