作者 邓超

x

... ... @@ -48,7 +48,8 @@ class Address {
$this->name = trim(str_replace([$email,'"','<','>','&gt;','&lt;'],'',$this->raw));
}
if($this->name){
$this->name = DeCode::decode($this->name);
// $this->name = DeCode::decode($this->name);
$this->name = Header::mime_decode($this->name);
}else{
$this->name = explode('@',$this->email)[0]??'';
}
... ...
... ... @@ -180,12 +180,7 @@ class Header{
* @time 2024/9/11 15:22
*/
public function getSubject():string {
$subject = explode("\n",$this->attributes['subject']??'');
foreach ($subject as $ak=>$str){
$subject[$ak] = DeCode::decode($str);
}
return implode("\n",$subject);
return static::mime_decode($this->attributes['subject']??'');
}
... ... @@ -264,4 +259,26 @@ class Header{
return $this->raw_header;
}
/**
* 解析加密字符
* @param string $str
* @return string
* @author:dc
* @time 2024/9/29 14:21
*/
public static function mime_decode(string $str):string {
$str = trim($str);
if(preg_match("/^=\?([a-z0-9-]{3,})\?[bq]\?/i",$str,$code)){
// 解码 这个函数好像已经转码了,
$str = mb_decode_mimeheader($str);
return $str;
// 转字符编码
// return mb_convert_encoding($str,'utf-8',$code[1]);
}
return $str;
}
}
... ...