FIX: remove invalid hack, correct whitelist to use value returned from callback
This commit is contained in:
parent
f2b554be13
commit
fbbd4999b6
|
@ -2057,7 +2057,13 @@ var html = (function(html4) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discourse modification: give us more flexibility with whitelists
|
// Discourse modification: give us more flexibility with whitelists
|
||||||
if (opt_nmTokenPolicy && opt_nmTokenPolicy(tagName, attribName, value)) { continue; }
|
if (opt_nmTokenPolicy) {
|
||||||
|
var newValue = opt_nmTokenPolicy(tagName, attribName, value);
|
||||||
|
if (newValue) {
|
||||||
|
attribs[i + 1] = newValue;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (atype !== null) {
|
if (atype !== null) {
|
||||||
switch (atype) {
|
switch (atype) {
|
||||||
|
|
|
@ -14,15 +14,6 @@ var _validClasses = {},
|
||||||
function validateAttribute(tagName, attribName, value) {
|
function validateAttribute(tagName, attribName, value) {
|
||||||
var tag = _validTags[tagName];
|
var tag = _validTags[tagName];
|
||||||
|
|
||||||
// Handle possible attacks
|
|
||||||
// if you include html in your markdown, it better be valid
|
|
||||||
//
|
|
||||||
// We are SUPER strict cause nokogiri will sometimes "correct"
|
|
||||||
// this stuff "incorrectly"
|
|
||||||
if(/[<>"'`]/.test(value)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle classes
|
// Handle classes
|
||||||
if (attribName === "class") {
|
if (attribName === "class") {
|
||||||
if (_validClasses[value]) { return value; }
|
if (_validClasses[value]) { return value; }
|
||||||
|
|
Loading…
Reference in New Issue