[BUGFIX:13.1] facet URL encoding mismatch (spaces) when using urlParameterStyle=assoc#4626
Merged
dkd-kaehm merged 1 commit intoTYPO3-Solr:release-13.1.xfrom May 1, 2026
Merged
Conversation
…Style=assoc ## Problem When using `faceting.urlParameterStyle = assoc`, facet links containing spaces in their values are rendered with an unresolved placeholder instead of the actual filter value: ?tx_solr[filter][materials:Material 1]=###tx_solr:filter:materials:Material 1### Values without spaces work correctly: ?tx_solr[filter][materials:Baustähle]=1 ## Root Cause In `SearchUriBuilder::buildLinkWithInMemoryCache()`, the placeholder keys for `str_replace` are computed using `urlencode()`, which encodes spaces as `+`. However, TYPO3's `UriBuilder` builds the URL template using `rawurlencode()` (RFC 3986), which encodes spaces as `%20`. The `str_replace` silently fails to find the `+`-encoded key in the `%20`-encoded template, leaving the raw `###...###` placeholder in the output. ## Fix Replace `urlencode()` with `rawurlencode()` in the second `$keys` computation (the one used for the actual `str_replace` against the URL template). This aligns the encoding with what TYPO3's `UriBuilder` produces. The first `$keys` block (passed to `BeforeCachedVariablesAreProcessedEvent`) is intentionally left unchanged to avoid side effects on existing event listeners. ## Affected versions Reproduced on EXT:solr 13.1.1 / TYPO3 13.4 with `urlParameterStyle = assoc`. --- - Use rawurlencode (spaces → %20) to match TYPO3's UriBuilder encoding. - urlencode encodes spaces as "+" which does not match "%20" in the URL template. Ports: TYPO3-Solr#4610
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.
Problem
When using
faceting.urlParameterStyle = assoc, facet links containing spacesin their values are rendered with an unresolved placeholder instead of the
actual filter value:
?tx_solr[filter][materials:Material 1]=###tx_solr:filter:materials:Material 1###
Values without spaces work correctly:
?tx_solr[filter][materials:Baustähle]=1
Root Cause
In
SearchUriBuilder::buildLinkWithInMemoryCache(), the placeholder keys forstr_replaceare computed usingurlencode(), which encodes spaces as+.However, TYPO3's
UriBuilderbuilds the URL template usingrawurlencode()(RFC 3986), which encodes spaces as
%20.The
str_replacesilently fails to find the+-encoded key in the%20-encoded template, leaving the raw###...###placeholder in the output.Fix
Replace
urlencode()withrawurlencode()in the second$keyscomputation(the one used for the actual
str_replaceagainst the URL template). Thisaligns the encoding with what TYPO3's
UriBuilderproduces.The first
$keysblock (passed toBeforeCachedVariablesAreProcessedEvent)is intentionally left unchanged to avoid side effects on existing event
listeners.
Affected versions
Reproduced on EXT:solr 13.1.1 / TYPO3 13.4 with
urlParameterStyle = assoc.Ports: #4610