From ff0124d74f1c869e4a200ead92f9bed7bf520621 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 12 Jan 2022 16:44:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20markdown=E5=9B=BE=E7=89=87=E5=90=8D?= =?UTF-8?q?=E6=98=AF=E4=B8=AD=E6=96=87=E7=9A=84=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/commons/utils/ShiroUtils.java | 3 +-- .../java/io/metersphere/controller/ResourceController.java | 4 ++-- .../components/track/case/components/MsMarkDownText.vue | 3 ++- .../components/track/review/commom/ReviewCommentItem.vue | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java index 752509843b..4b4f1963b2 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java @@ -15,7 +15,7 @@ public class ShiroUtils { public static void loadBaseFilterChain(Map filterChainDefinitionMap) { - filterChainDefinitionMap.put("/resource/md/get/*", "anon"); + filterChainDefinitionMap.put("/resource/md/get", "anon"); filterChainDefinitionMap.put("/*.worker.js", "anon"); filterChainDefinitionMap.put("/login", "anon"); filterChainDefinitionMap.put("/signin", "anon"); @@ -78,7 +78,6 @@ public class ShiroUtils { filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf filterChainDefinitionMap.put("/test/case/file/preview/**", "apikey, authc"); // 预览测试用例附件 不用校验 csrf filterChainDefinitionMap.put("/mock", "apikey, authc"); // 跳转到 /mock接口 不用校验 csrf - filterChainDefinitionMap.put("/resource/md/get/**", "apikey, authc"); } public static Cookie getSessionIdCookie() { diff --git a/backend/src/main/java/io/metersphere/controller/ResourceController.java b/backend/src/main/java/io/metersphere/controller/ResourceController.java index f00e1de30b..eec6614a26 100644 --- a/backend/src/main/java/io/metersphere/controller/ResourceController.java +++ b/backend/src/main/java/io/metersphere/controller/ResourceController.java @@ -20,8 +20,8 @@ public class ResourceController { resourceService.mdUpload(request, file); } - @GetMapping(value = "/md/get/{fileName}") - public ResponseEntity getFile(@PathVariable("fileName") String fileName) { + @GetMapping(value = "/md/get") + public ResponseEntity getFile(@RequestParam ("fileName") String fileName) { return resourceService.getMdImage(fileName); } diff --git a/frontend/src/business/components/track/case/components/MsMarkDownText.vue b/frontend/src/business/components/track/case/components/MsMarkDownText.vue index da7f1838f1..7fc0a5ccaf 100644 --- a/frontend/src/business/components/track/case/components/MsMarkDownText.vue +++ b/frontend/src/business/components/track/case/components/MsMarkDownText.vue @@ -154,7 +154,8 @@ export default { this.result.loading = true; uploadMarkDownImg(file, (response, param) => { this.$success(this.$t('commons.save_success')); - this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + param.fileName); + let url = '/resource/md/get?fileName=' + param.id + '_' + encodeURIComponent(param.fileName); + this.$refs.md.$img2Url(pos, url); this.result.loading = false; }); this.$emit('imgAdd', file); diff --git a/frontend/src/business/components/track/review/commom/ReviewCommentItem.vue b/frontend/src/business/components/track/review/commom/ReviewCommentItem.vue index f26b99ad1c..d84ba76039 100644 --- a/frontend/src/business/components/track/review/commom/ReviewCommentItem.vue +++ b/frontend/src/business/components/track/review/commom/ReviewCommentItem.vue @@ -168,9 +168,9 @@ export default { let returnFlag = false; if (param) { let message = param + ""; - let matchIndex = message.indexOf("](/resource/md/get/"); + let matchIndex = message.indexOf("](/resource/md/get"); if (matchIndex > 0) { - let messageSplitArr = message.split("](/resource/md/get/"); + let messageSplitArr = message.split("](/resource/md/get"); for (let itemIndex = 0; itemIndex < messageSplitArr.length; itemIndex++) { let itemStr = messageSplitArr[itemIndex]; let picNameIndex = itemStr.indexOf("!["); @@ -183,7 +183,7 @@ export default { this.imgNameList.push(itemStrArr); } - let imgUrl = "/resource/md/get/" + itemStrArr; + let imgUrl = "/resource/md/get" + itemStrArr; this.src = imgUrl; if (this.srcList.indexOf(itemStrArr) < 0) { this.srcList.push(imgUrl);