File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1053,7 +1053,7 @@ export class Toolbar {
10531053 }
10541054 inlineMemoElements . forEach ( ( item ) => {
10551055 if ( item . nodeType !== 3 ) {
1056- item . setAttribute ( "data-inline-memo-content" , Lute . EscapeHTMLStr ( textElement . value ) ) ;
1056+ item . setAttribute ( "data-inline-memo-content" , window . DOMPurify . sanitize ( textElement . value ) ) ;
10571057 }
10581058 } ) ;
10591059 } else {
@@ -1131,7 +1131,7 @@ export class Toolbar {
11311131 }
11321132 } else if ( item . nodeType !== 3 ) {
11331133 // 行级备注自动移除换行 https://ld246.com/article/1664205917326
1134- item . setAttribute ( "data-inline-memo-content" , Lute . EscapeHTMLStr ( textElement . value ) ) ;
1134+ item . setAttribute ( "data-inline-memo-content" , window . DOMPurify . sanitize ( textElement . value ) ) ;
11351135 }
11361136 } ) ;
11371137 } else if ( types . includes ( "inline-math" ) ) {
Original file line number Diff line number Diff line change @@ -134,18 +134,16 @@ const setHTML = (options: {
134134 return ;
135135 }
136136
137- if ( DOMPurify ) {
138- // XSS in inline memo elements https://github.com/siyuan-note/siyuan/issues/15280
139- const parser = new DOMParser ( ) ;
140- const doc = parser . parseFromString ( options . content , "text/html" ) ;
141- doc . querySelectorAll ( "[data-inline-memo-content]" ) . forEach ( item => {
142- const content = item . getAttribute ( "data-inline-memo-content" ) ;
143- if ( content ) {
144- item . setAttribute ( "data-inline-memo-content" , DOMPurify . sanitize ( content ) ) ;
145- }
146- } ) ;
147- options . content = doc . body . innerHTML ;
148- }
137+ // XSS in inline memo elements https://github.com/siyuan-note/siyuan/issues/15280
138+ const parser = new DOMParser ( ) ;
139+ const doc = parser . parseFromString ( options . content , "text/html" ) ;
140+ doc . querySelectorAll ( "[data-inline-memo-content]" ) . forEach ( item => {
141+ const content = item . getAttribute ( "data-inline-memo-content" ) ;
142+ if ( content ) {
143+ item . setAttribute ( "data-inline-memo-content" , window . DOMPurify . sanitize ( content ) ) ;
144+ }
145+ } ) ;
146+ options . content = doc . body . innerHTML ;
149147
150148 protyle . block . showAll = options . action . includes ( Constants . CB_GET_ALL ) ;
151149 const REMOVED_OVER_HEIGHT = protyle . contentElement . clientHeight * 8 ;
Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ interface CSSStyleDeclarationElectron extends CSSStyleDeclaration {
140140}
141141
142142interface Window {
143+ DOMPurify : {
144+ sanitize ( dirty : string ) : string ;
145+ } ;
143146 echarts : {
144147 init ( element : Element , theme ?: string , options ?: {
145148 width : number
You can’t perform that action at this time.
0 commit comments