From 240a201bf1bda49a37ebef154a767c1d19367653 Mon Sep 17 00:00:00 2001 From: Devil Date: Tue, 27 Jul 2021 12:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=20=E7=BC=96=E8=BE=91=E5=99=A8=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=8A=93=E5=8F=96=E5=9B=BE=E7=89=87=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/UeditorService.php | 1 + extend/base/Uploader.php | 23 ++------------- .../static/common/lib/ueditor/ueditor.all.js | 28 +++++++++---------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/app/service/UeditorService.php b/app/service/UeditorService.php index cac6fe3ee..aeeeb837a 100644 --- a/app/service/UeditorService.php +++ b/app/service/UeditorService.php @@ -307,6 +307,7 @@ class UeditorService $ret = ResourcesService::AttachmentAdd($data); if($ret['code'] == 0) { + $ret['data']['source'] = htmlspecialchars($imgUrl); array_push($list, $ret['data']); } } diff --git a/extend/base/Uploader.php b/extend/base/Uploader.php index f43ce204e..7a4c15dba 100755 --- a/extend/base/Uploader.php +++ b/extend/base/Uploader.php @@ -375,29 +375,12 @@ class Uploader return; } - //获取请求头并检测死链 - $heads = get_headers($imgUrl, 1); - if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) { + //打开输出缓冲区并获取远程图片 + $img = RequestGet($imgUrl); + if(empty($img)) { $this->stateInfo = $this->getStateInfo("ERROR_DEAD_LINK"); return; } - //格式验证(扩展名验证和Content-Type验证) - $fileType = strtolower(strrchr($imgUrl, '.')); - if (!in_array($fileType, $this->config['allowFiles']) || !isset($heads['Content-Type']) || !stristr($heads['Content-Type'], "image")) { - $this->stateInfo = $this->getStateInfo("ERROR_HTTP_CONTENTTYPE"); - return; - } - - //打开输出缓冲区并获取远程图片 - ob_start(); - $context = stream_context_create( - array('http' => array( - 'follow_location' => false // don't follow redirects - )) - ); - readfile($imgUrl, false, $context); - $img = ob_get_contents(); - ob_end_clean(); preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m); $this->oriName = $m ? $m[1]:""; diff --git a/public/static/common/lib/ueditor/ueditor.all.js b/public/static/common/lib/ueditor/ueditor.all.js index 4f3075e8b..83fd3d89b 100755 --- a/public/static/common/lib/ueditor/ueditor.all.js +++ b/public/static/common/lib/ueditor/ueditor.all.js @@ -23253,21 +23253,19 @@ UE.plugins['catchremoteimage'] = function () { } /* 获取源路径和新路径 */ - var i, newSrc, list = info.data || null; - if(list == null || list.length <= 0 || list.length != imgs.length) - { - return; - } - - // 循环处理图片替换 - for (i = 0; i