From ea507289a92da042e26cf4b562114971ecda4931 Mon Sep 17 00:00:00 2001 From: GregcodeOhm Date: Fri, 10 Jul 2026 19:42:17 +0200 Subject: [PATCH] FIX #39038 Double quote in product label truncates the combo (#39051) In select_produits_list() the product option data-html attribute is built by concatenating $labeltoshowhtml, $outvalUnits and $labeltoshowhtmlprice as raw strings. The variables that carry user text are $labeltoshowhtml (ref, customer ref, barcode and product label) and $outvalUnits (unit short label from the dictionary), so a double quote typed there, for example an inch mark 1/2", closes the data-html="..." attribute early and the rich dropdown (ajaxcombo) shows the name truncated at the quote. $labeltoshowhtmlprice only carries outputs of price() and transnoentities() and cannot contain a double quote. Sanitize the two user variables with dolPrintHTMLForAttribute(), as the stock part of the same attribute already does. The tag 'strong' is passed in the allowothertags parameter for the label so the search highlight added around the typed filter key is kept in the rich label. Base 21.0: the data-html attribute on the product option was introduced in 21.0; on 20.0 the option carried only a class and select2 used the plain option text where a quote is harmless. In develop the code was reworked by PR #39057 which now escapes the whole value with dol_escape_htmltag(), so this fix targets the maintained branches only. Signed-off-by: Gregory Aliot --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3135f37a879..c7a3e5430b0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3620,11 +3620,11 @@ class Form } if ($stocktag == 1) { - $opt .= ' class="product_line_stock_ok" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).'"'; + $opt .= ' class="product_line_stock_ok" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml, 0, array('strong')).dolPrintHTMLForAttribute($outvalUnits).$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).'"'; //$opt .= ' class="product_line_stock_ok"'; } if ($stocktag == -1) { - $opt .= ' class="product_line_stock_too_low" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).'"'; + $opt .= ' class="product_line_stock_too_low" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml, 0, array('strong')).dolPrintHTMLForAttribute($outvalUnits).$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).'"'; //$opt .= ' class="product_line_stock_too_low"'; }