2
0
forked from Wavyzz/dolibarr

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2023-12-29 16:53:09 +01:00
6 changed files with 158 additions and 77 deletions

View File

@@ -264,12 +264,23 @@ class CMailFile
// This convert an embedd file with src="/viewimage.php?modulepart... into a cid link
// TODO Exclude viewimage used for the read tracker ?
$findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias');
if ($findimg<0) {
dol_syslog("CMailFile::CMailfile: Error on findHtmlImages");
$this->error = 'ErrorInAddAttachementsImageBaseOnMedia';
return;
}
}
if (getDolGlobalString('MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA')) {
// Search into the body for <img src="data:image/ext;base64,..." to replace them with an embedded file
// This convert an embedded file with src="data:image... into a cid link + attached file
$findimg = $this->findHtmlImagesIsSrcData($upload_dir_tmp);
$resultImageData = $this->findHtmlImagesIsSrcData($upload_dir_tmp);
if ($resultImageData<0) {
dol_syslog("CMailFile::CMailfile: Error on findHtmlImagesInSrcData");
$this->error = 'ErrorInAddAttachementsImageBaseOnMedia';
return;
}
$findimg += $resultImageData;
}
// Set atleastoneimage if there is at least one embedded file (into ->html_images)
@@ -1902,7 +1913,7 @@ class CMailFile
// We search (into mail body this->html), if we find some strings like "... file=xxx.img"
// For example when:
// <img alt="" src="/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/picture.jpg" style="height:356px; width:1040px" />
// <img alt="" src="/src="data:image....;base64,...." />
$matches = array();
preg_match_all('/src="data:image\/('.implode('|', $extensions).');base64,([^"]+)"/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found
@@ -1913,7 +1924,7 @@ class CMailFile
return -1;
}
$i = 0;
$i = count($this->html_images);
foreach ($matches[1] as $key => $ext) {
// We save the image to send in disk
$filecontent = $matches[2][$key];