File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,19 @@ const isImageBlock = el => {
9393 return el && el . classList . contains ( 'stk-block-image' )
9494}
9595
96+ function sanitize ( string ) {
97+ const map = {
98+ '&' : '&' ,
99+ '<' : '<' ,
100+ '>' : '>' ,
101+ '"' : '"' ,
102+ "'" : ''' ,
103+ '/' : '/' ,
104+ }
105+ const reg = / [ & < > " ' / ] / ig
106+ return string . replace ( reg , match => map [ match ] )
107+ }
108+
96109class StackableImageLightbox {
97110 init = ( ) => {
98111 this . elements = [ ]
@@ -135,6 +148,10 @@ class StackableImageLightbox {
135148 title = imageBlock . getAttribute ( 'alt' ) || null
136149 }
137150
151+ // Sanitize strings.
152+ title = title ? sanitize ( title ) : null
153+ link = typeof link === 'string' ? sanitize ( link ) : link
154+
138155 const isUsingImageBlock = ( ! link || ! href ) && imageBlock
139156
140157 this . elements . push ( {
You can’t perform that action at this time.
0 commit comments