mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FIX: remove dangerous support for style/background attributes in polls
This commit is contained in:
@ -3,19 +3,14 @@ export default Em.Component.extend({
|
||||
classNames: ["results"],
|
||||
|
||||
options: function() {
|
||||
const voters = this.get("poll.voters"),
|
||||
backgroundColor = this.get("poll.background");
|
||||
const voters = this.get("poll.voters");
|
||||
|
||||
this.get("poll.options").forEach(option => {
|
||||
const percentage = voters === 0 ? 0 : Math.floor(100 * option.get("votes") / voters),
|
||||
styles = ["width: " + percentage + "%"];
|
||||
|
||||
if (backgroundColor) { styles.push("background: " + backgroundColor); }
|
||||
const percentage = voters === 0 ? 0 : Math.floor(100 * option.get("votes") / voters);
|
||||
|
||||
option.setProperties({
|
||||
percentage,
|
||||
title: I18n.t("poll.option_title", { count: option.get("votes") }),
|
||||
style: styles.join(";").htmlSafe()
|
||||
title: I18n.t("poll.option_title", { count: option.get("votes") })
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user