Skip to content

Commit 9e65e7a

Browse files
committed
fix: strip html tags for gist id to avoid stored XSS on showing error [Security Issue]
Signed-off-by: Max Wu <[email protected]>
1 parent 8c20d9f commit 9e65e7a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

public/js/extra.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ export function finishView (view) {
330330
})
331331
// gist
332332
view.find('code[data-gist-id]').each((key, value) => {
333-
if ($(value).children().length === 0) { $(value).gist(window.viewAjaxCallback) }
333+
if ($(value).children().length === 0) {
334+
// strip HTML tags to avoid stored XSS
335+
const gistid = value.getAttribute('data-gist-id')
336+
value.setAttribute('data-gist-id', stripTags(gistid))
337+
$(value).gist(window.viewAjaxCallback)
338+
}
334339
})
335340
// sequence diagram
336341
const sequences = view.find('div.sequence-diagram.raw').removeClass('raw')

0 commit comments

Comments
 (0)