Skip to content

[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
dkd-kaehm:ports/4610_13.1.x
May 1, 2026
Merged

[BUGFIX:13.1] facet URL encoding mismatch (spaces) when using urlParameterStyle=assoc#4626
dkd-kaehm merged 1 commit intoTYPO3-Solr:release-13.1.xfrom
dkd-kaehm:ports/4610_13.1.x

Conversation

@dkd-kaehm
Copy link
Copy Markdown
Collaborator

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: #4610

…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
@dkd-kaehm dkd-kaehm merged commit 50674c9 into TYPO3-Solr:release-13.1.x May 1, 2026
12 checks passed
@dkd-kaehm dkd-kaehm deleted the ports/4610_13.1.x branch May 1, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants