File size: 1,334 Bytes
eb67da4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
(function(document) {
if ((typeof window.MathJax != 'undefined') && (typeof window.MathJax.Hub != 'undefined')) {
// Apply MathJax typesetting
var mathjaxDiv =
document.getElementById(config.mathjaxProcessingElementId);
// Apply Markdown parser after MathJax typesetting is complete
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub,
mathjaxDiv]);
window.MathJax.Hub.Register.StartupHook("End Typeset",
function () {
// BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
//
// FIXED:
config.markedOptions.sanitize = false;
marked.setOptions(config.markedOptions);
// Decode < and >
mathjaxData = mathjaxDiv.innerHTML;
mathjaxData = mathjaxData.replace(/</g, "<");
mathjaxData = mathjaxData.replace(/>/g, ">");
// Convert Markdown to HTML and replace document body
var html = marked(mathjaxData);
document.body.innerHTML = html;
// Remove div used for MathJax processing
mathjaxDiv.remove();
}
);
}
}(document));
|