Problem/Motivation
When the module detects duplicate query parameters and rebuilds the URL for redirect, it double-encodes the parameter values. The raw (already URL-encoded) value from the query string is passed directly to UrlHelper::buildQuery(), which encodes it a second time.
For example, a URL with ?search_api_fulltext=vendor+resource+center&search_api_fulltext=vendor+resource+center gets redirected to ?search_api_fulltext=vendor%2Bresource%2Bcenter, causing the server to interpret the value as the literal string vendor+resource+center instead of vendor resource center.
Note that the key is already correctly decoded with urldecode() on line 54, but the same treatment is missing for the value on line 56.
This is especially problematic on sites using Views with AJAX enabled (use_ajax: true), where Drupal core's ajax_view.js appends the current window.location.search to the AJAX URL, and jQuery Form plugin appends the serialized form fields - resulting in duplicate parameters that are legitimate and expected by core.
Steps to reproduce
1. Install the module on a site with a Views page that has use_ajax: true and an exposed fulltext search filter (e.g., Search API).
2. Navigate to the view with a multi-word search keyword, e.g., /search?search_api_fulltext=vendor+resource+center.
3. Confirm the results and keyword field display correctly on initial page load.
4. Click the "Search" (or "Apply"/"Filter") button on the exposed filter form without changing anything.
5. Observe that the keyword field now shows vendor%2Bresource%2Bcenter (or vendor%20resource%20center depending on the original encoding) and no results are returned.
Proposed resolution
Decode the value with urldecode() before storing it, matching the existing treatment of the key. This way UrlHelper::buildQuery() receives a decoded string and encodes it exactly once.
// Before (line 56):
$value = $parts[1] ?? '';
// After:
$value = urldecode($parts[1] ?? '');
Remaining tasks
Review and commit the patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3580937-fix_double_encoding_on_redirect-02.patch | 808 bytes | danyg |
Comments
Comment #2
danyg commentedComment #4
ahmedx commentedPatch reviewed, tested, and committed. Thanks @danyg!