FIX dol_concatdesc to escape <

Better help
This commit is contained in:
Laurent Destailleur 2020-05-14 14:10:04 +02:00
parent 1bd00b0e8c
commit bcaa83eeec
5 changed files with 16 additions and 10 deletions

View File

@ -592,7 +592,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<input type="text" name="operationparam">';
$htmltext = $langs->transnoentitiesnoconv("OperationParamDesc");
//var_dump($htmltext);
print $form->textwithpicto('', $htmltext);
print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'operationparamtt');
print '</td>';
print '<td></td>';
print '<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button" value="'.$langs->trans("Add").'"></td>';
@ -643,7 +643,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
// Delete
print '<td class="right nowraponall">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editoperation&operationid='.$ruleaction['id'].'">'.img_edit().'</a>';
print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editoperation&operationid='.$ruleaction['id'].'">'.img_edit().'</a>';
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>';
print '</td>';
print '</tr>';

View File

@ -308,7 +308,7 @@ class Translate
continue;
}
else {
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
// Convert some strings: Parse and render carriage returns. Also, change '\\s' into '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
if ($usecachekey) {
$tabtranslatedomain[$key] = $value;

View File

@ -5794,7 +5794,8 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
/**
* Replace CRLF in string with a HTML BR tag
* Replace CRLF in string with a HTML BR tag.
* WARNING: The content after operation contains some HTML tags (the <br>) so be sure to also have encode the special chars of stringtoencode into HTML before.
*
* @param string $stringtoencode String to encode
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
@ -6048,7 +6049,7 @@ function dol_textishtml($msg, $option = 0)
*
* @param string $text1 Text 1
* @param string $text2 Text 2
* @param bool $forxml false=Use <br>instead of \n if html content detected, true=Use <br /> instead of \n if html content detected
* @param bool $forxml true=Use <br /> instead of <br> if we have to add a br tag
* @param bool $invert invert order of description lines (we often use config MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION in this parameter)
* @return string Text 1 + new line + Text2
* @see dol_textishtml()
@ -6063,9 +6064,9 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
}
$ret = '';
$ret .= (!dol_textishtml($text1) && dol_textishtml($text2)) ?dol_nl2br($text1, 0, $forxml) : $text1;
$ret .= (!dol_textishtml($text1) && dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text1, 0, 1, '', 1), 0, $forxml) : $text1;
$ret .= (!empty($text1) && !empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2)) ? ($forxml ? "<br \>\n" : "<br>\n") : "\n") : "";
$ret .= (dol_textishtml($text1) && !dol_textishtml($text2)) ?dol_nl2br($text2, 0, $forxml) : $text2;
$ret .= (dol_textishtml($text1) && !dol_textishtml($text2)) ? dol_nl2br(dol_escape_htmltag($text2, 0, 1, '', 1), 0, $forxml) : $text2;
return $ret;
}

View File

@ -937,8 +937,8 @@ class EmailCollector extends CommonObject
}
imap_errors(); // Clear stack of errors.
// $conf->global->MAIL_PREFIX_FOR_EMAIL_ID must be defined
$host = dol_getprefix('email');
//$host = '123456';
// Define the IMAP search string
// See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible)
@ -1081,6 +1081,7 @@ class EmailCollector extends CommonObject
dol_syslog("Start of loop on email", LOG_INFO, 1);
$i = 0;
foreach ($arrayofemail as $imapemail)
{
if ($nbemailprocessed > 1000)
@ -1088,6 +1089,8 @@ class EmailCollector extends CommonObject
break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect
}
$i++;
$header = imap_fetchheader($connection, $imapemail, 0);
$header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines
$matches = array();
@ -1095,6 +1098,8 @@ class EmailCollector extends CommonObject
$headers = array_combine($matches[1], $matches[2]);
//var_dump($headers);
dol_syslog("** Process email ".$i." References: ".$headers['References']);
// If there is a filter on trackid
if ($searchfilterdoltrackid > 0)
{
@ -1130,7 +1135,7 @@ class EmailCollector extends CommonObject
// GET Email meta datas
$overview = imap_fetch_overview($connection, $imapemail, 0);
dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject);
dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject);
// Decode $overview[0]->subject according to RFC2047
// Can use also imap_mime_header_decode($str)

View File

@ -1939,7 +1939,7 @@ WithoutDolTrackingID=Dolibarr Reference not found in Message ID
FormatZip=Zip
MainMenuCode=Menu entry code (mainmenu)
ECMAutoTree=Show automatic ECM tree
OperationParamDesc=Define values to use for action, or how to extract values. For example:<br>objproperty1=SET:abc<br>objproperty1=SET:a value with replacement of __objproperty1__<br>objproperty3=SETIFEMPTY:abc<br>objproperty4=EXTRACT:HEADER:X-Myheaderkey.*[^\s]+(.*)<br>options_myextrafield=EXTRACT:SUBJECT:([^\s]*)<br>object.objproperty5=EXTRACT:BODY:My company name is\s([^\s]*)<br><br>Use a ; char as separator to extract or set several properties.
OperationParamDesc=Define the values to use for the object of the action, or how to extract values. For example:<br>objproperty1=SET:the value to set<br>objproperty2=SET:a value with replacement of __objproperty1__<br>objproperty3=SETIFEMPTY:value used if objproperty3 is not already defined<br>objproperty4=EXTRACT:HEADER:X-Myheaderkey:\s*([^\s]*)<br>options_myextrafield1=EXTRACT:SUBJECT:([^&#92;n]*)<br>object.objproperty5=EXTRACT:BODY:My company name is\s([^\s]*)<br><br>Use a ; char as separator to extract or set several properties.
OpeningHours=Opening hours
OpeningHoursDesc=Enter here the regular opening hours of your company.
ResourceSetup=Configuration of Resource module