Problem/Motivation
If a user searches for a term and accidentally adds a space (" ") at the end of the search term, instead of trimming the search term and looking it up, an error appears:
Invalid URI: A URI must not start nor end with ASCII control characters or spaces.
Steps to reproduce
- Create a search page.
- Go to that search page.
- Search the term "test ".
- See the error appearing.
Proposed resolution
Trime searched terms.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork search_api_page-3523613
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyI can confirm this. Input should definitely always be trimmed for this reason. As it causes a hard exception, I'd say this is high prio.
Comment #4
grevil commentedDone, please review.
Comment #5
anybodySimple, but effective fix! :) Thanks!
Comment #6
danheisel commentedThanks for this fix. It has solved most of my team's search errors from users but it left the error when directly accessing a search result URL. Lately, a site my team maintains has been hit with crawlers attempting to access search results using seemingly valid queries that are appropriate for the site content. While we sort through which crawlers are valid, we are getting quite a few pages in the logs that still fail with this error. The crawlers are accessing the result pages directly with URLs like, "/search/test%20". The error does not appear on the search page if the query string is used instead of the clean URL. The only fix for the clean URL option that we found for this was to trim the keys on PathProcessorSearchApiPage in the ProcessInbound function. This also seems to clean it up for the form and results.
Comment #9
karlshea