From 8d8debd441f0a012856cbfeca76cb26cca60f5d3 Mon Sep 17 00:00:00 2001 From: w3houde Date: Tue, 9 Jun 2026 19:07:07 +0200 Subject: [PATCH] Fix #38171 Allow underscore in extrafields old-syntax filter regex (#38506) ExtraFields::showInputField normalises the legacy "(field=123)" filter syntax of "List from a table" extrafields into the modern USF "(field:=:123)" form. The compatibility regex "/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i" only accepts alphanumeric field names, so a filter like "fk_typent=2" does not match, the filter is left as is, and forgeSQLFromUniversalSearchCriteria later fails with "Filter error" because the raw expression is not valid universal search syntax. Accept the underscore character in the field name class, the rest of the predicate is untouched. The two identical occurrences in the file (one per branch of the dispatch) are updated. Reported and root cause pinpointed by @stephanebourdon-cmyk. Signed-off-by: Dolicraft Co-authored-by: Dolicraft --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 77f53bcf85d..8acedbe22b8 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1408,7 +1408,7 @@ class ExtraFields // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9_]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; } @@ -1638,7 +1638,7 @@ class ExtraFields // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9_]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; }