Skip to content

Strip HTML tags for gist id to avoid stored XSS on showing error [Security Issue] #1691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion public/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,20 @@ export function finishView (view) {
})
// gist
view.find('code[data-gist-id]').each((key, value) => {
if ($(value).children().length === 0) { $(value).gist(window.viewAjaxCallback) }
if ($(value).children().length === 0) {
// strip HTML tags to avoid stored XSS
const gistid = value.getAttribute('data-gist-id')
value.setAttribute('data-gist-id', stripTags(gistid))
const gistfile = value.getAttribute('data-gist-file')
if (gistfile) value.setAttribute('data-gist-file', stripTags(gistfile))
const gistline = value.getAttribute('data-gist-line')
if (gistline) value.setAttribute('data-gist-line', stripTags(gistline))
const gisthighlightline = value.getAttribute('data-gist-highlight-line')
if (gisthighlightline) value.setAttribute('data-gist-highlight-line', stripTags(gisthighlightline))
const gistshowloading = value.getAttribute('data-gist-show-loading')
if (gistshowloading) value.setAttribute('data-gist-show-loading', stripTags(gistshowloading))
$(value).gist(window.viewAjaxCallback)
}
})
// sequence diagram
const sequences = view.find('div.sequence-diagram.raw').removeClass('raw')
Expand Down