作者 邓超

1

... ... @@ -91,7 +91,7 @@ class Body {
}
else{
// qq的是base64
if(rtrim($body,'=') == rtrim(base64_encode(base64_decode($body)),'=')){
if(MailFun::isBase64($body)){
$this->setItem(['type'=>'text/plain','body'=>base64_decode($body)]);
}else{
$this->setItem(['type'=>'text/plain','body'=>$body]);
... ...
... ... @@ -330,15 +330,8 @@ class Mail {
foreach ($body as $key=>$item){
if(!$description && in_array($item['type']??'',['text/html','text/plain'])){
// 是否是base64
$value = @base64_decode($item['body']);
if(!$value){
$value = $item['body'];
}
if(!empty($item['charset'])){
$value = iconv($item['charset'],'utf-8',$value);
$value = iconv($item['charset'],'utf-8',$item['body']);
}
$value=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$value); //过滤script标签
$value=preg_replace("/<(\/?script.*?)>/si","",$value); //过滤script标签
... ... @@ -349,6 +342,7 @@ class Mail {
$value = strip_tags($value);
$value = str_replace(["\n",' ',"\\n","&nbsp;"],'',$value);
$description = mb_substr(trim($value),0,190);
}
if(!empty($body[$key]['body'])){
... ...
... ... @@ -195,4 +195,16 @@ class MailFun {
return mb_convert_encoding($folder,'UTF7-IMAP','UTF-8');
}
/**
* 是否是base64
* @param $str
* @return bool
* @author:dc
* @time 2023/4/3 10:24
*/
public static function isBase64($str){
$oldStr = str_replace([' ',"\n","\r"],'',rtrim($str,'='));
return $oldStr == base64_encode(base64_decode($str));
}
}
... ...