mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 15:42:29 +01:00
add unit test for image in email with src=../media/ or src=base64
This commit is contained in:
@@ -263,12 +263,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 (!empty($conf->global->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 = $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)
|
||||
@@ -1847,7 +1858,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&entity=1&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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user