diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 03751120c7b..792ed58ab2b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -190,7 +190,12 @@ class Form $morealt=' style="width: '.$cols.'"'; $cols=''; } - $ret.=''; + + $valuetoshow = ($editvalue?$editvalue:$value); + + $ret.=''; } else if ($typeofdata == 'day' || $typeofdata == 'datepicker') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e6e3a240878..92ee1e11122 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5014,7 +5014,7 @@ function picto_required() * @param string $pagecodeto Encoding of input/output string * @return string String cleaned * - * @see dol_escape_htmltag strip_tags + * @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags */ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8') { @@ -5041,6 +5041,50 @@ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF- return trim($temp); } +/** + * Clean a string to keep only desirable HTML tags. + * + * @param string $stringtoclean String to clean + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags + */ +function dol_string_onlythesehtmltags($stringtoclean) +{ + $allowed_tags = array( + "html", "head", "meta", "body", "b", "br", "div", "em", "font", "img", "hr", "i", "li", "link", + "ol", "p", "s", "section", "span", "strong", "title", + "table", "tr", "th", "td", "u", "ul" + ); + + $allowed_tags_string = join("><", $allowed_tags); + $allowed_tags_string = preg_replace('/^>/','',$allowed_tags_string); + $allowed_tags_string = preg_replace('/<$/','',$allowed_tags_string); + + $temp = strip_tags($stringtoclean, $allowed_tags_string); + + return $temp; +} + +/** + * Clean a string from some undesirable HTML tags. + * + * @param string $stringtoclean String to clean + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags + */ +function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea')) +{ + $temp = $stringtoclean; + foreach($disallowed_tags as $tagtoremove) + { + $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp); + $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp); + } + return $temp; +} + /** * Return first line of text. Cut will depends if content is HTML or not.