mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 18:13:58 +08:00
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
|
||||
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) {
|
||||
switch (atype) {
|
||||
|
|
|
@ -14,15 +14,6 @@ var _validClasses = {},
|
|||
function validateAttribute(tagName, attribName, value) {
|
||||
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
|
||||
if (attribName === "class") {
|
||||
if (_validClasses[value]) { return value; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user