Fix: duplicate entity encoding into select_array.

This commit is contained in:
Laurent Destailleur 2014-09-08 23:08:59 +02:00
parent a3bbf2aff9
commit 2fb806bfc2
2 changed files with 6 additions and 5 deletions

View File

@ -3932,11 +3932,12 @@ class Form
/** /**
* Return a HTML select string, built from an array of key+value. * Return a HTML select string, built from an array of key+value.
* Note: Do not use returned string into a langs->trans function, content may be entity encoded twice.
* *
* @param string $htmlname Name of html select area * @param string $htmlname Name of html select area
* @param array $array Array with key+value * @param array $array Array with key+value
* @param string $id Preselected key * @param string $id Preselected key
* @param int $show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon * @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or ' ').
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" * @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key * @param int $value_as_key 1 to use value as key
* @param string $moreparam Add more parameters onto the select tag * @param string $moreparam Add more parameters onto the select tag
@ -3945,7 +3946,7 @@ class Form
* @param int $disabled Html select box is disabled * @param int $disabled Html select box is disabled
* @param int $sort 'ASC' or 'DESC' =Sort on label, '' or 'NONE'=Do not sort * @param int $sort 'ASC' or 'DESC' =Sort on label, '' or 'NONE'=Do not sort
* @param string $morecss Add more class to css styles * @param string $morecss Add more class to css styles
* @return string HTML select string * @return string HTML select string.
*/ */
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='') static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
{ {
@ -3982,11 +3983,11 @@ class Form
if ($key_in_label) if ($key_in_label)
{ {
$selectOptionValue = dol_htmlentitiesbr($key.' - '.($maxlen?dol_trunc($value,$maxlen):$value)); $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen?dol_trunc($value,$maxlen):$value));
} }
else else
{ {
$selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($value,$maxlen):$value); $selectOptionValue = dol_escape_htmltag($maxlen?dol_trunc($value,$maxlen):$value);
if ($value == '' || $value == '-') $selectOptionValue=' '; if ($value == '' || $value == '-') $selectOptionValue=' ';
} }
$out.=$selectOptionValue; $out.=$selectOptionValue;

View File

@ -337,7 +337,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
width: "500px" */ width: "500px" */
$msg = '<script type="text/javascript"> $msg = '<script type="text/javascript">
$(function() { $(document).ready(function() {
$("#'.$htmlname.'").combobox({ $("#'.$htmlname.'").combobox({
minLengthToAutocomplete : '.$minLengthToAutocomplete.', minLengthToAutocomplete : '.$minLengthToAutocomplete.',
selected : function(event,ui) { selected : function(event,ui) {