Issue Bug Closed

#110482selectTree filter throws on regular expression meta characters

Georg Ringer 08/13/26, 19:20 updated 09/08/26, 10:03

Description

The search field of a TCA selectTree passes the typed value straight into the
@RegExp@ constructor without escaping it:

// Build/Sources/TypeScript/backend/form-engine/element/select-tree.ts
public override filter(searchTerm?: string|null): void {
  ...
  const regex = new RegExp(searchTerm, 'i');

The value is user input, taken directly from the search field:

// Build/Sources/TypeScript/backend/form-engine/element/select-tree-toolbar.ts
<input type="search" ... @input="${(evt: InputEvent) => this.filter(evt)}">
...
private filter(event: InputEvent): void {
  const inputEl = <HTMLInputElement>event.target;
  this.tree.filter(inputEl.value.trim());
}

How to reproduce

  • Open a record with a TCA field using renderType = selectTree, for example the
    category tree of a content element
  • Type an opening bracket into the “Find item” search field

Result

new RegExp('(', 'i') throws a SyntaxError, the input handler dies and the filter
silently stops working. Entering an ordinary title such as “Müller & Söhne (GmbH)” is
enough to trigger it.

Expected

The search term is treated as literal text, as everywhere else.

Notes

This is the same defect that #107565 fixed for
@form-engine/element/extra/select-box-filter.ts@ – the selectTree filter was not
touched back then.

Since the search term is escaped to a literal anyway, the RegExp can be dropped in
favour of String.includes() on a normalized string, which also removes the need for the
escaping in the first place. That is the same direction proposed for #83788, which asks
for accent insensitive filtering in the side by side select. Fixing both filters the same
way would make them behave consistently.

Reviews 2

History 25

  1. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-08-28T09:40:11+00:00" > 08/28/26, 09:40 </span>

    Applied in changeset commit:06206a8ae69c47f11aa93a1ff0ca4d720205c396.