Search Block with trailing space in keys: BadRequestException

Created on 22 November 2024, 26 days ago

Problem/Motivation

This is the first time I've reported an issue so my apologies if I'm doing it wrong. After updating to Drupal to 10.3.9 from 10.3.6, we started receiving the error below on Search API pages.

Symfony\Component\HttpFoundation\Exception\BadRequestException: Invalid URI: A URI must not start nor end with ASCII control characters or spaces. in Symfony\Component\HttpFoundation\Request::create() (line 371 of /code/vendor/symfony/http-foundation/Request.php).

Steps to reproduce

This would happen when a search was submitted on a Search API Block where the query had a trailing space which would take the user to something like: //mySearchTerm%20 while //mySearchTerm would work fine.

It looks like it's related to this issue:

https://www.drupal.org/project/drupal/issues/3486195 🐛 An update to symfony/http-foundation plus a trailing space took down the views UI Active

Proposed resolution

I attached a patch that trims the 'keys' on submit, but I'm not a php expert so I'm sure someone else can make it better and more official. Or perhaps this would be addressed later within Drupal Core and this isn't necessary.

Remaining tasks

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024