Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: correctly render html of event title #623

Merged
merged 4 commits into from
Oct 22, 2024
Merged

Conversation

jjaffeux
Copy link
Contributor

This has been lost during the move to glimmer.

This has been lost during the move to glimmer.
Comment on lines 57 to 62
return htmlSafe(
emojiUnescape(
escapeExpression(this.args.event.name) ||
this.args.event.post.topic.title
)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to escape topic.title as well.

If we want to keep this all manual, then I think we should split it up like:

Suggested change
return htmlSafe(
emojiUnescape(
escapeExpression(this.args.event.name) ||
this.args.event.post.topic.title
)
);
const unsafeRawTitle = this.args.event.name || this.args.event.post.topic.title;
const escapedTitle = escapeExpression(unsafeRawTitle);
const escapedTitleWithEmoji = emojiUnescape(escapedTitle);
return htmlSafe(escapedTitleWithEmoji);

Or, even better, we can do the emoji escaping using our hbs helper which has all the escaping built-in.

So make the getter a simple thing like:

get eventName(){
  return this.args.event.name || this.args.event.post.topic.title;
}

and then import/use the helper:
...

import replaceEmoji from "discourse/helpers/replace-emoji";
...
<template>
  {{replaceEmoji this.eventName}}
</template>

Co-Authored-By: David Taylor <[email protected]>
@jjaffeux jjaffeux merged commit ee693e3 into main Oct 22, 2024
5 checks passed
@jjaffeux jjaffeux deleted the html-safe-event-title branch October 22, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants