|
@@ -1286,9 +1286,9 @@ function dol_escape_json($stringtoescape)
|
|
|
* Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
|
|
|
*
|
|
|
* @param string $stringtoescape String to escape
|
|
|
- * @param int $keepb 1=Keep b tags, 0=remove them completeley
|
|
|
+ * @param int $keepb 1=Keep b tags, 0=remove them completely
|
|
|
* @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a <textarea>.
|
|
|
- * @param string $noescapetags '' or 'common' or list of tags to not escape
|
|
|
+ * @param string $noescapetags '' or 'common' or list of tags to not escape. TODO Does not works yet when there is attributes to tag.
|
|
|
* @param int $escapeonlyhtmltags 1=Escape only html tags, not the special chars like accents.
|
|
|
* @return string Escaped string
|
|
|
* @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent()
|
|
@@ -1296,7 +1296,7 @@ function dol_escape_json($stringtoescape)
|
|
|
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags = '', $escapeonlyhtmltags = 0)
|
|
|
{
|
|
|
if ($noescapetags == 'common') {
|
|
|
- $noescapetags = 'html,body,a,b,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
|
|
|
+ $noescapetags = 'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
|
|
|
}
|
|
|
|
|
|
// escape quotes and backslashes, newlines, etc.
|
|
@@ -1316,15 +1316,16 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapeta
|
|
|
return htmlspecialchars($tmp, ENT_COMPAT, 'UTF-8');
|
|
|
} else {
|
|
|
// Escape tags to keep
|
|
|
+ // TODO Does not works yet when there is attributes to tag
|
|
|
$tmparrayoftags = array();
|
|
|
if ($noescapetags) {
|
|
|
$tmparrayoftags = explode(',', $noescapetags);
|
|
|
}
|
|
|
-
|
|
|
if (count($tmparrayoftags)) {
|
|
|
foreach ($tmparrayoftags as $tagtoreplace) {
|
|
|
$tmp = str_ireplace('<'.$tagtoreplace.'>', '__BEGINTAGTOREPLACE'.$tagtoreplace.'__', $tmp);
|
|
|
$tmp = str_ireplace('</'.$tagtoreplace.'>', '__ENDTAGTOREPLACE'.$tagtoreplace.'__', $tmp);
|
|
|
+ $tmp = str_ireplace('<'.$tagtoreplace.' />', '__BEGINENDTAGTOREPLACE'.$tagtoreplace.'__', $tmp);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1334,6 +1335,7 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapeta
|
|
|
foreach ($tmparrayoftags as $tagtoreplace) {
|
|
|
$result = str_ireplace('__BEGINTAGTOREPLACE'.$tagtoreplace.'__', '<'.$tagtoreplace.'>', $result);
|
|
|
$result = str_ireplace('__ENDTAGTOREPLACE'.$tagtoreplace.'__', '</'.$tagtoreplace.'>', $result);
|
|
|
+ $result = str_ireplace('__BEGINENDTAGTOREPLACE'.$tagtoreplace.'__', '<'.$tagtoreplace.' />', $result);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -10453,7 +10455,7 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
|
|
|
|
|
|
/**
|
|
|
* Create a button to copy $valuetocopy in the clipboard.
|
|
|
- * Code that handle the click is inside lib_foot.jsp.php
|
|
|
+ * Code that handle the click is inside lib_foot.jsp.php.
|
|
|
*
|
|
|
* @param string $valuetocopy The value to print
|
|
|
* @param int $showonlyonhover Show the copy-paste button only on hover
|
|
@@ -10469,10 +10471,11 @@ function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $tex
|
|
|
$showonlyonhover = 0;
|
|
|
}*/
|
|
|
|
|
|
+ $tag = 'span'; // Using div does not work when using the js copy code.
|
|
|
if ($texttoshow) {
|
|
|
- $result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><span class="clipboardCPValue hidewithsize">'.$valuetocopy.'</span><span class="clipboardCPValueToPrint">'.$texttoshow.'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText opacitymedium"></span></span>';
|
|
|
+ $result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><'.$tag.' class="clipboardCPValue hidewithsize">'.dol_escape_htmltag($valuetocopy, 1, 1).'</'.$tag.'><span class="clipboardCPValueToPrint">'.dol_escape_htmltag($texttoshow, 1, 1).'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText opacitymedium"></span></span>';
|
|
|
} else {
|
|
|
- $result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><span class="clipboardCPValue">'.$valuetocopy.'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText opacitymedium"></span></span>';
|
|
|
+ $result = '<span class="clipboardCP'.($showonlyonhover ? ' clipboardCPShowOnHover' : '').'"><'.$tag.' class="clipboardCPValue">'.dol_escape_htmltag($valuetocopy, 1, 1).'</'.$tag.'><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText opacitymedium"></span></span>';
|
|
|
}
|
|
|
|
|
|
return $result;
|