作者 邓超

1

@@ -459,21 +459,27 @@ class Home extends Base { @@ -459,21 +459,27 @@ class Home extends Base {
459 $body = db()->first(bodySql::first($id)); 459 $body = db()->first(bodySql::first($id));
460 if($body){ 460 if($body){
461 $data['body'] = json_decode($body['text_html'],true); 461 $data['body'] = json_decode($body['text_html'],true);
462 - $charset = ''; 462 + $charset = 'utf-8';
  463 + $htmlbody = '';
463 foreach ($data['body'] as $bd){ 464 foreach ($data['body'] as $bd){
464 - if(!empty($bd['charset'])){  
465 - $charset = $bd['charset'];  
466 - break; 465 +// if(!empty($bd['charset'])){
  466 +// $charset = $bd['charset'];
  467 +// }
  468 + if(($bd['type']??'') == 'text/html'){
  469 + $htmlbody = base64_decode($bd['body']);
467 } 470 }
468 } 471 }
469 foreach ($data['body'] as $bdk=>$bd){ 472 foreach ($data['body'] as $bdk=>$bd){
470 473
471 if(!empty($bd['path'])){ 474 if(!empty($bd['path'])){
472 475
473 - if($charset){  
474 - $data['body'][$bdk]['name'] = @iconv($charset,'utf-8',@base64_decode($bd['name']));  
475 - $data['body'][$bdk]['filename'] = @iconv($charset,'utf-8',@base64_decode($bd['filename']));  
476 - } 476 + $data['body'][$bdk]['name'] = @base64_decode($bd['name']);
  477 + $data['body'][$bdk]['filename'] = @base64_decode($bd['filename']);
  478 + // 进行编码转换 会出现未知bug
  479 +// if($charset && strtolower($charset) != 'utf-8' && strtolower($charset) != 'utf8'){
  480 +// $data['body'][$bdk]['name'] = @iconv($charset,'utf-8',$data['body'][$bdk]['name']);
  481 +// $data['body'][$bdk]['filename'] = @iconv($charset,'utf-8',$data['body'][$bdk]['filename']);
  482 +// }
477 483
478 $data['body'][$bdk]['size'] = 0; 484 $data['body'][$bdk]['size'] = 0;
479 $data['body'][$bdk]['url'] = ''; 485 $data['body'][$bdk]['url'] = '';
@@ -484,7 +490,25 @@ class Home extends Base { @@ -484,7 +490,25 @@ class Home extends Base {
484 $data['body'][$bdk]['url'] = APP_HOST.str_replace(PUBLIC_PATH,'',$bd['path']); 490 $data['body'][$bdk]['url'] = APP_HOST.str_replace(PUBLIC_PATH,'',$bd['path']);
485 } 491 }
486 492
  493 + // 验证编码是否有其他编码字符,这里编辑了未知编码
  494 + if(!@json_encode($data['body'][$bdk])){
  495 + // 抛弃原有的名字,显示已存储到服务器的名字
  496 + $data['body'][$bdk]['name'] = $data['body'][$bdk]['signName'];
  497 + $data['body'][$bdk]['filename'] = $data['body'][$bdk]['signName'];
  498 + }
  499 +
487 unset($data['body'][$bdk]['path']); 500 unset($data['body'][$bdk]['path']);
  501 +
  502 + // 内容区是有有cid
  503 + if ($htmlbody && !empty($bd['content-id'])){
  504 + if(!strpos($htmlbody,"\"cid:{$bd['content-id']}\"")){
  505 + unset($data['body'][$bdk]['content-id']);
  506 + }
  507 + }
  508 + // 没有html内容,content-id是不可能有的
  509 + else if(!$htmlbody){
  510 + unset($data['body'][$bdk]['content-id']);
  511 + }
488 } 512 }
489 } 513 }
490 return [ 514 return [