From 9b1cf648dcb2601a64beb43c283086f8a42bc182 Mon Sep 17 00:00:00 2001 From: torvista Date: Mon, 21 Jan 2019 16:19:31 +0100 Subject: [PATCH] more validation fixes --- htdocs/core/class/html.formactions.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 22 +++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2d86379d42f..15db641a5ec 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -224,8 +224,8 @@ class FormActions print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'class="center"', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'class="right"', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); print ''; print "\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6db21a9c41f..77bc072fd62 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2950,7 +2950,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo * @return string Return img tag * @see #img_object, #img_picto_common */ -function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly=0, $notitle=0, $alt='', $morecss='') +function img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath = false, $srconly=0, $notitle=0, $alt='', $morecss='') { global $conf, $langs; @@ -3074,14 +3074,22 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $facolor = '#444'; $marginleftonlyshort=0; } - + //this snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. + //class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes $reg=array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss.= ($morecss?' ':'').$reg[1]; - } + $morecss .= ($morecss ? ' ' : '') . $reg[1]; + $moreatt = str_replace('class="'.$reg[1].'"','', $moreatt); + } + if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { + $morestyle = ' '. $reg[1]; + $moreatt = str_replace('style="'.$reg[1].'"','', $moreatt); + } + $moreatt=trim($moreatt); + $fa='fa'; if (! empty($conf->global->MAIN_USE_FONT_AWESOME_5)) $fa='fas'; - $enabledisablehtml = ''; + $enabledisablehtml = ''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml.= $titlealt; } @@ -3130,7 +3138,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if ($srconly) { return $fullpathpicto; } - // tag title is used for tooltip on , tag alt can be used with very simple text on image for bind people + // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } @@ -3285,7 +3293,7 @@ function img_edit_remove($titlealt = 'default', $other='') * @param string $other Add more attributes on img * @return string Return tag img */ -function img_edit($titlealt = 'default', $float = 0, $other = 'class="pictoedit"') +function img_edit($titlealt = 'default', $float = 0, $other = '') { global $conf, $langs;