From 5fad2c3a14c9e3014510f1934ffabaffeaec60c0 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:15:25 +0100 Subject: [PATCH 1/3] Fix dolGetButton Tooltip --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 95f69e8e3fe..461b6b43c52 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12520,7 +12520,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = } // escape all attribute - $attr = array_map('dol_escape_htmltag', $attr); + $attr = array_map('dol_htmlentities', $attr); $TCompiledAttr = array(); foreach ($attr as $key => $value) { From 4b640e4cad9311834515f0acc079d8557dcdf191 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:29:47 +0100 Subject: [PATCH 2/3] Add params --- htdocs/core/lib/functions.lib.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 461b6b43c52..b610cc4decf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12344,6 +12344,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'xxxxx' => '', // your xxxxx attribute you want * 'class' => 'reposition', // to add more css class to the button class attribute * 'classOverride' => '' // to replace class attribute of the button + * 'use_unsecured_unescapedattr' => [] | bool // on true will use unsecured fonction to escape all attributes, if use array it will use unsecured fonction to escape attribute key present in this array * ], * 'confirm' => [ * 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. @@ -12519,8 +12520,22 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = unset($attr['href']); } - // escape all attribute - $attr = array_map('dol_htmlentities', $attr); + // Escape all attributes + if (!empty($params['use_unsecured_unescapedattr'])) { + if (is_array($params['use_unsecured_unescapedattr'])) { + foreach ($attr as $attrK => $attrV) { + if (in_array($attrK, $params['use_unsecured_unescapedattr'])) { + $attr[$attrK] = dol_htmlentities($attrV, ENT_QUOTES | ENT_SUBSTITUTE); + } else { + $attr[$attrK] = dolPrintHtmlForAttribute($attrV); + } + } + } else { + $attr = array_map('dol_htmlentities', $attr); + } + } else { + $attr = array_map('dolPrintHtmlForAttribute', $attr); + } $TCompiledAttr = array(); foreach ($attr as $key => $value) { From da8d69e1abbb919d54e56aa9723bf3ef02aac802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Mar 2025 14:57:54 +0100 Subject: [PATCH 3/3] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b610cc4decf..6b804f62a19 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12521,20 +12521,20 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = } // Escape all attributes - if (!empty($params['use_unsecured_unescapedattr'])) { + if (!empty($params['use_unsecured_unescapedattr'])) { // Not recommended. if (is_array($params['use_unsecured_unescapedattr'])) { foreach ($attr as $attrK => $attrV) { if (in_array($attrK, $params['use_unsecured_unescapedattr'])) { $attr[$attrK] = dol_htmlentities($attrV, ENT_QUOTES | ENT_SUBSTITUTE); } else { - $attr[$attrK] = dolPrintHtmlForAttribute($attrV); + $attr[$attrK] = dolPrintHTMLForAttribute($attrV); } } } else { $attr = array_map('dol_htmlentities', $attr); } } else { - $attr = array_map('dolPrintHtmlForAttribute', $attr); + $attr = array_map('dolPrintHTMLForAttribute', $attr); } $TCompiledAttr = array();