正在显示
1 个修改的文件
包含
31 行增加
和
25 行删除
@@ -118,6 +118,10 @@ class Body { | @@ -118,6 +118,10 @@ class Body { | ||
118 | 118 | ||
119 | 119 | ||
120 | }else{ | 120 | }else{ |
121 | + if(isset($header['Content-Transfer-Encoding'])){ | ||
122 | + $body = $this->decode($header['Content-Transfer-Encoding'],$body); | ||
123 | + } | ||
124 | + | ||
121 | $this->setItem(['type'=>'text/plain','body'=>$body]); | 125 | $this->setItem(['type'=>'text/plain','body'=>$body]); |
122 | } | 126 | } |
123 | 127 | ||
@@ -345,31 +349,7 @@ class Body { | @@ -345,31 +349,7 @@ class Body { | ||
345 | }else{ | 349 | }else{ |
346 | // tag | 350 | // tag |
347 | 351 | ||
348 | - $data['body'] = $tempbody; | ||
349 | - | ||
350 | - // body解密 | ||
351 | - switch($data['encode']??''){ | ||
352 | - case 'base64': { | ||
353 | - $data['body'] = base64_decode($data['body']); | ||
354 | - break; | ||
355 | - } | ||
356 | - case 'quoted-printable': { | ||
357 | - $data['body'] = quoted_printable_decode($data['body']); | ||
358 | - break; | ||
359 | - } | ||
360 | - case '8bit': { | ||
361 | - try { | ||
362 | -// $data['body'] = DeCoding::de8bit($data['body']); | ||
363 | - // 暂时没有替换 imap_8bit的函数 | ||
364 | - $data['body'] = imap_8bit($data['body']); | ||
365 | - $data['body'] = quoted_printable_decode($data['body']); | ||
366 | - }catch (\Throwable $e){ | ||
367 | - | ||
368 | - } | ||
369 | - | ||
370 | - break; | ||
371 | - } | ||
372 | - } | 352 | + $data['body'] = $this->decode($data['encode']??'',$tempbody); |
373 | 353 | ||
374 | // 转码 | 354 | // 转码 |
375 | // if(isset($data['charset']) && $data['charset']){ | 355 | // if(isset($data['charset']) && $data['charset']){ |
@@ -400,6 +380,32 @@ class Body { | @@ -400,6 +380,32 @@ class Body { | ||
400 | 380 | ||
401 | } | 381 | } |
402 | 382 | ||
383 | + private function decode($code,$body){ | ||
384 | + switch($code){ | ||
385 | + case 'base64': { | ||
386 | + $data['body'] = base64_decode($body); | ||
387 | + break; | ||
388 | + } | ||
389 | + case 'quoted-printable': { | ||
390 | + $data['body'] = quoted_printable_decode($body); | ||
391 | + break; | ||
392 | + } | ||
393 | + case '8bit': { | ||
394 | + try { | ||
395 | +// $data['body'] = DeCoding::de8bit($data['body']); | ||
396 | + // 暂时没有替换 imap_8bit的函数 | ||
397 | + $body = imap_8bit($body); | ||
398 | + $body = quoted_printable_decode($body); | ||
399 | + }catch (\Throwable $e){ | ||
400 | + | ||
401 | + } | ||
402 | + | ||
403 | + break; | ||
404 | + } | ||
405 | + } | ||
406 | + return $body; | ||
407 | + } | ||
408 | + | ||
403 | 409 | ||
404 | /** | 410 | /** |
405 | * 解析文件 | 411 | * 解析文件 |
-
请 注册 或 登录 后发表评论