-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
[Block] SearchAffects the Search Block - used to display a search fieldAffects the Search Block - used to display a search field[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
When searching for a term containing an apostrophe (e.g. "ada's"), the search input field on the results page displays ada's instead of ada's. This is because get_search_query() returns a pre-escaped string, and WP_HTML_Tag_Processor::set_attribute() escapes it again, causing double-encoding.
Step-by-step reproduction instructions
- Add a Search block to any page or template
- On the frontend, search for a term containing an apostrophe, e.g.
ada's - On the search results page, observe the search input field displays
ada'sinstead ofada's
Screenshots, screen recording, code snippet
Environment info
The bug exists in the latest trunk. The issue is in packages/block-library/src/search/index.php line 82. The fix is to pass false to get_search_query() so set_attribute() handles escaping:
// Before:
$input->set_attribute( 'value', get_search_query() );
// After:
$input->set_attribute( 'value', get_search_query( false ) );Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Block] SearchAffects the Search Block - used to display a search fieldAffects the Search Block - used to display a search field[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended