mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 08:44:48 +08:00
FIX: prevent self-xss in poll attributes
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
const WHITELISTED_ATTRIBUTES = ["type", "name", "min", "max", "step", "order", "color", "background", "status"];
|
||||
const WHITELISTED_STYLES = ["color", "background"];
|
||||
|
||||
const ATTRIBUTES_REGEX = new RegExp("(" + WHITELISTED_ATTRIBUTES.join("|") + ")=['\"]?[^\\s\\]]+['\"]?", "g");
|
||||
const ATTRIBUTES_REGEX = new RegExp("(" + WHITELISTED_ATTRIBUTES.join("|") + ")=['\"]?[^\\s\\]=]+['\"]?", "g");
|
||||
|
||||
Discourse.Dialect.replaceBlock({
|
||||
start: /\[poll([^\]]*)\]([\s\S]*)/igm,
|
||||
@ -45,7 +45,7 @@
|
||||
// extract poll attributes
|
||||
(matches[1].match(ATTRIBUTES_REGEX) || []).forEach(function(m) {
|
||||
var attr = m.split("="), name = attr[0], value = attr[1];
|
||||
value = value.replace(/["']/g, "");
|
||||
value = Handlebars.Utils.escapeExpression(value.replace(/["']/g, ""));
|
||||
attributes[DATA_PREFIX + name] = value;
|
||||
});
|
||||
|
||||
@ -98,12 +98,6 @@
|
||||
contents[0][o].splice(1, 0, attr);
|
||||
}
|
||||
|
||||
// // add some information when type is "multiple"
|
||||
// if (attributes[DATA_PREFIX + "type"] === "multiple") {
|
||||
|
||||
|
||||
// }
|
||||
|
||||
var result = ["div", attributes],
|
||||
poll = ["div"];
|
||||
|
||||
|
Reference in New Issue
Block a user