From 1644a54eb116b685a3f4b40408bb48db217bb0c0 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Sat, 2 Dec 2023 14:05:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhtml=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-commom/pom.xml | 5 ----- .../service/impl/GroupMessageServiceImpl.java | 6 +++--- im-ui/src/components/chat/ChatBox.vue | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/im-commom/pom.xml b/im-commom/pom.xml index bf1e555..43fb929 100644 --- a/im-commom/pom.xml +++ b/im-commom/pom.xml @@ -59,11 +59,6 @@ java-jwt 3.11.0 - - com.google.guava - guava - 32.1.2-jre - org.slf4j diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java index 3ca8b03..0e8d8eb 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java @@ -2,7 +2,7 @@ package com.bx.implatform.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -73,7 +73,7 @@ public class GroupMessageServiceImpl extends ServiceImpl
-
{ if (node.nodeName == "#text") { - sendText = document.getElementById("inputText").innerHTML; + sendText += this.html2Escape(node.textContent); } else if (node.nodeName == "SPAN") { sendText += node.innerText; } else if (node.nodeName == "IMG") { @@ -230,6 +230,16 @@ }) return sendText; }, + html2Escape(strHtml) { + return strHtml.replace(/[<>&"]/g, function(c) { + return { + '<': '<', + '>': '>', + '&': '&', + '"': '"' + }[c]; + }); + }, createAtUserIds() { let ids = []; this.$refs.editBox.childNodes.forEach((node) => {