From 0cd25d99bff424ecd27ca7fa299e4509c699d9c0 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Fri, 21 Jul 2023 00:38:39 +0800 Subject: [PATCH] refactor: skip div attr process in xss --- .../src/group/GroupCustomWebPanelRender.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx b/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx index 4274442f..38387441 100644 --- a/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx +++ b/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useRef, useState } from 'react'; import { Translate } from '../translate'; -import { FilterXSS, filterXSS, getDefaultWhiteList, IWhiteList } from 'xss'; +import { FilterXSS } from 'xss'; import { useWatch } from '@capital/common'; -import { GroupExtraDataPanel, TextArea } from '@capital/component'; +import { GroupExtraDataPanel, NoData, TextArea } from '@capital/component'; import styled from 'styled-components'; const EditModalContent = styled.div` @@ -27,7 +27,9 @@ const EditModalContent = styled.div` const xss = new FilterXSS({ css: false, onIgnoreTag: function (tag, html, options) { - if (['html', 'body', 'head', 'meta', 'style', 'iframe'].includes(tag)) { + if ( + ['html', 'body', 'head', 'meta', 'style', 'iframe', 'div'].includes(tag) + ) { // 不对其属性列表进行过滤 return html; } @@ -63,7 +65,7 @@ const GroupCustomWebPanelRender: React.FC<{ html: string }> = (props) => { }, [html]); if (!html) { - return
{Translate.notfound}
; + return ; } return