Merge pull request #1193 from hackmdio/fix-render-view-error-msg-XSS

Fix stored XSS in the graphviz error message rendering [Security Issue]
This commit is contained in:
Max Wu 2019-04-14 20:36:27 -04:00 committed by GitHub
commit 9d7413d596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -333,7 +333,7 @@ export function finishView (view) {
svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet') svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet')
} catch (err) { } catch (err) {
$value.unwrap() $value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + err + '</div>') $value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err) console.warn(err)
} }
}) })
@ -357,7 +357,7 @@ export function finishView (view) {
$value.children().unwrap().unwrap() $value.children().unwrap().unwrap()
} catch (err) { } catch (err) {
$value.unwrap() $value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + err + '</div>') $value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err) console.warn(err)
} }
}) })
@ -376,7 +376,7 @@ export function finishView (view) {
$value.children().unwrap().unwrap() $value.children().unwrap().unwrap()
} catch (err) { } catch (err) {
$value.unwrap() $value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + err + '</div>') $value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err) console.warn(err)
} }
}) })
@ -398,7 +398,7 @@ export function finishView (view) {
} }
$value.unwrap() $value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + errormessage + '</div>') $value.parent().append(`<div class="alert alert-warning">${escapeHTML(errormessage)}</div>`)
console.warn(errormessage) console.warn(errormessage)
} }
}) })
@ -418,7 +418,7 @@ export function finishView (view) {
svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet') svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet')
} catch (err) { } catch (err) {
$value.unwrap() $value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + err + '</div>') $value.parent().append(`<div class="alert alert-warning">${escapeHTML(err)}</div>`)
console.warn(err) console.warn(err)
} }
}) })
@ -578,7 +578,7 @@ export function postProcess (code) {
if (warning && warning.length > 0) { if (warning && warning.length > 0) {
warning.text(md.metaError) warning.text(md.metaError)
} else { } else {
warning = $('<div id="meta-error" class="alert alert-warning">' + md.metaError + '</div>') warning = $(`<div id="meta-error" class="alert alert-warning">${escapeHTML(md.metaError)}</div>`)
result.prepend(warning) result.prepend(warning)
} }
} }