From 0635c9b01733089bf07aa21dc5bf750558428900 Mon Sep 17 00:00:00 2001 From: msgroup Date: Wed, 2 Mar 2022 16:13:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BE=E5=BA=A6=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/action/web/EditorAction.java | 83 +++++++++++++ .../WEB-INF/manager/include/head-file.ftl | 114 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100755 src/main/java/net/mingsoft/basic/action/web/EditorAction.java create mode 100644 src/main/webapp/WEB-INF/manager/include/head-file.ftl diff --git a/src/main/java/net/mingsoft/basic/action/web/EditorAction.java b/src/main/java/net/mingsoft/basic/action/web/EditorAction.java new file mode 100755 index 00000000..a1097785 --- /dev/null +++ b/src/main/java/net/mingsoft/basic/action/web/EditorAction.java @@ -0,0 +1,83 @@ +/** + * The MIT License (MIT) + * Copyright (c) 2012-2022 铭软科技(mingsoft.net) + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +package net.mingsoft.basic.action.web; + +import cn.hutool.core.io.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.mingsoft.ueditor.MsUeditorActionEnter; +import net.mingsoft.basic.util.BasicUtil; +import net.mingsoft.config.MSProperties; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 临时修复:百度编辑器上传,会在下一版本合并 + * + * @author 铭软开发团队 + * @date 2019年7月16日 + * 历史修订 2022-1-21 新增normalize(), + * editor()方法过滤非法上传路径 + */ +@ApiIgnore +@Controller("ueAction") +@RequestMapping("/static/plugins/ueditor/{version}/jsp") +public class EditorAction { + + @ResponseBody + @RequestMapping(value = "editor", method = {RequestMethod.GET, RequestMethod.POST}) + public String editor(HttpServletRequest request, HttpServletResponse response, String jsonConfig) { + String uploadFloderPath = MSProperties.upload.path; + String rootPath = BasicUtil.getRealPath(uploadFloderPath); + jsonConfig = jsonConfig.replace("{ms.upload}", "/" + uploadFloderPath); + //过滤非法上传路径 + Map map = (Map) JSONObject.parse(jsonConfig); + String imagePathFormat = (String) map.get("imagePathFormat"); + imagePathFormat = FileUtil.normalize(imagePathFormat); + + String filePathFormat = (String) map.get("filePathFormat"); + filePathFormat = FileUtil.normalize(filePathFormat); + + String videoPathFormat = (String) map.get("videoPathFormat"); + videoPathFormat = FileUtil.normalize(videoPathFormat); + + map.put("imagePathFormat", imagePathFormat); + map.put("filePathFormat", filePathFormat); + map.put("videoPathFormat", videoPathFormat); + + jsonConfig = JSONObject.toJSONString(map); + MsUeditorActionEnter actionEnter = new MsUeditorActionEnter(request, rootPath, jsonConfig, BasicUtil.getRealPath("")); + String json = actionEnter.exec(); + Map jsonMap = JSON.parseObject(json,Map.class); + jsonMap.put("url","/".concat(uploadFloderPath).concat(jsonMap.get("url")+"")); + return JSONObject.toJSONString(jsonMap); + } + +} diff --git a/src/main/webapp/WEB-INF/manager/include/head-file.ftl b/src/main/webapp/WEB-INF/manager/include/head-file.ftl new file mode 100644 index 00000000..36645cae --- /dev/null +++ b/src/main/webapp/WEB-INF/manager/include/head-file.ftl @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<#--复制--> + +<#-- 树形下拉--> + + + +<#--主题--> + + + + + +<#--语言文件--> + + + + + +<#--下拉框--> + + + +<#--代码预览--> + + + + + + + + + + + + +