fix(漏洞): 新闻、通知加xss过滤

This commit is contained in:
ZhangZhiYi
2026-08-13 11:42:51 +08:00
parent a66e9e1441
commit 284b714c1e
7 changed files with 166 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package com.fastbee.iot.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.common.utils.html.RichTextSanitizer;
import com.fastbee.iot.mapper.NewsCategoryMapper;
import com.fastbee.iot.model.CategoryNews;
import com.fastbee.iot.model.IdAndName;
@@ -88,6 +89,7 @@ public class NewsServiceImpl implements INewsService
@Override
public int insertNews(News news)
{
news.setContent(RichTextSanitizer.sanitize(news.getContent()));
news.setCreateTime(DateUtils.getNowDate());
return newsMapper.insertNews(news);
}
@@ -101,6 +103,7 @@ public class NewsServiceImpl implements INewsService
@Override
public int updateNews(News news)
{
news.setContent(RichTextSanitizer.sanitize(news.getContent()));
news.setUpdateTime(DateUtils.getNowDate());
return newsMapper.updateNews(news);
}

View File

@@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update news
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="content != null">content = #{content},</if>
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
<if test="isTop != null">is_top = #{isTop},</if>
<if test="isBanner != null">is_banner = #{isBanner},</if>
@@ -124,4 +124,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{newsId}
</foreach>
</delete>
</mapper>
</mapper>

View File

@@ -1,6 +1,7 @@
package com.fastbee.system.service.impl;
import java.util.List;
import com.fastbee.common.utils.html.RichTextSanitizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.system.domain.SysNotice;
@@ -51,6 +52,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
@Override
public int insertNotice(SysNotice notice)
{
notice.setNoticeContent(RichTextSanitizer.sanitize(notice.getNoticeContent()));
return noticeMapper.insertNotice(notice);
}
@@ -63,6 +65,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
@Override
public int updateNotice(SysNotice notice)
{
notice.setNoticeContent(RichTextSanitizer.sanitize(notice.getNoticeContent()));
return noticeMapper.updateNotice(notice);
}