File tree Expand file tree Collapse file tree
amis-editor/src/renderer/textarea-formula
amis-ui/src/components/formula Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55import { TextareaFormulaControlProps } from './TextareaFormulaControl' ;
66import { FormulaEditor } from 'amis-ui' ;
7+ import { escapeHtml } from 'amis-core' ;
78import type { VariableItem , CodeMirror } from 'amis-ui' ;
89
910export function editorFactory (
@@ -232,7 +233,7 @@ export class FormulaPlugin {
232233 true ,
233234 false
234235 ) || {
235- html : expression
236+ html : escapeHtml ( expression )
236237 } ;
237238
238239 const wrap = document . createElement ( 'span' ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import React from 'react';
55import {
66 eachTree ,
77 resolveVariableAndFilterForAsync ,
8- uncontrollable
8+ uncontrollable ,
9+ escapeHtml
910} from 'amis-core' ;
1011import {
1112 parse ,
@@ -208,7 +209,8 @@ export class FormulaEditor extends React.Component<
208209 . filter ( item => item )
209210 . sort ( ( a , b ) => b . length - a . length ) ;
210211
211- const content = value || '' ;
212+ // XSS 防护:对用户输入进行转义
213+ const content = escapeHtml ( value || '' ) ;
212214 let html = '' ;
213215
214216 // 标记方法调用
You can’t perform that action at this time.
0 commit comments