diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39a0d9754e0..cd75f7c803d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1591,9 +1591,9 @@ class Form if (empty($outputmode)) { if (in_array($obj->rowid, $selected)) { - $out .= ''; + $out .= ''; } else { - $out .= ''; + $out .= ''; } } else { array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label, 'labelhtml' => $labelhtml)); @@ -8612,9 +8612,10 @@ class Form $out .= ' selected'; } if (!empty($tmplabelhtml)) { - $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml) . '"'; + $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml, 0, 0, '', 0, 1) . '"'; } else { - $out .= ' data-html="' . dol_escape_htmltag(($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval) . '"'; + $tmplabelhtml = ($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval; + $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml, 0, 0, '', 0, 1) . '"'; } $out .= '>'; $out .= dol_htmlentitiesbr($newval); @@ -8631,7 +8632,9 @@ class Form if ($addjscombo == 1) { $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; $out .= 'function formatResult(record, container) {' . "\n"; - $out .= ' if ($(record.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(record.element).attr("data-html")); // If property html set, we decode html entities and use this' . "\n"; + // If property html set, we decode html entities and use this. + // Note that HTML content must have been sanitized from js with dol_escape_htmltag(xxx, 0, 0, '', 0, 1) when building the select option. + $out .= ' if ($(record.element).attr("data-html") != undefined) { return htmlEntityDecodeJs($(record.element).attr("data-html")); }'."\n"; $out .= ' return record.text;'; $out .= '}' . "\n"; $out .= 'function formatSelection(record) {' . "\n"; diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 1c29ffc2597..37c0bfc6744 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -464,7 +464,7 @@ function urlencode(s) { /* * ================================================================= - * Purpose: Clean string to have it url encoded + * Purpose: Clean string to get a HTML coded string. * Input: s * Author: Laurent Destailleur * Licence: GPL diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 3a95809e6d4..34ca110dd1e 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -506,11 +506,15 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = templateResult: function (data, container) { /* Format visible output into combo list */ /* Code to add class of origin OPTION propagated to the new select2