Skip to content

A platform for community discussion. Free, open, simple.

FIX: poll ensure ranked choice results can handle options with rich text and links (#28195)

Robertc95f9dbf34e0
diff --git a/plugins/poll/assets/javascripts/discourse/components/poll-results-ranked-choice.gjs b/plugins/poll/assets/javascripts/discourse/components/poll-results-ranked-choice.gjs
index 77b37731e84..9d717d0d0ae 100644
--- a/plugins/poll/assets/javascripts/discourse/components/poll-results-ranked-choice.gjs
+++ b/plugins/poll/assets/javascripts/discourse/components/poll-results-ranked-choice.gjs
@@ -1,13 +1,16 @@
import Component from "@glimmer/component";
+import { htmlSafe } from "@ember/template";
import i18n from "discourse-common/helpers/i18n";
import I18n from "discourse-i18n";
export default class PollResultsRankedChoiceComponent extends Component {
get rankedChoiceWinnerText() {
- return I18n.t("poll.ranked_choice.winner", {
- count: this.args.rankedChoiceOutcome.round_activity.length,
- winner: this.args.rankedChoiceOutcome.winning_candidate.html,
- });
+ return htmlSafe(
+ I18n.t("poll.ranked_choice.winner", {
+ count: this.args.rankedChoiceOutcome.round_activity.length,
+ winner: this.args.rankedChoiceOutcome.winning_candidate.html,
+ })
+ );
}
get rankedChoiceTiedText() {
@@ -33,7 +36,7 @@ export default class PollResultsRankedChoiceComponent extends Component {
{{#if round.majority}}
<tr>
<td>{{round.round}}</td>
- <td>{{round.majority.html}}</td>
+ <td>{{htmlSafe round.majority.html}}</td>
<td>{{i18n "poll.ranked_choice.none"}}</td>
</tr>
{{else}}
@@ -42,7 +45,7 @@ export default class PollResultsRankedChoiceComponent extends Component {
<td>{{i18n "poll.ranked_choice.none"}}</td>
<td>
{{#each round.eliminated as |eliminated|}}
- {{eliminated.html}}
+ {{htmlSafe eliminated.html}}
{{/each}}
</td>
</tr>
@@ -59,9 +62,9 @@ export default class PollResultsRankedChoiceComponent extends Component {
>{{this.rankedChoiceTiedText}}</span>
<ul class="poll-results-ranked-choice-tied-candidates">
{{#each @rankedChoiceOutcome.tied_candidates as |tied_candidate|}}
- <li
- class="poll-results-ranked-choice-tied-candidate"
- >{{tied_candidate.html}}</li>
+ <li class="poll-results-ranked-choice-tied-candidate">{{htmlSafe
+ tied_candidate.html
+ }}</li>
{{/each}}
</ul>
{{else}}