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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { service } from "@ember/service";
import { modifier } from "ember-modifier";
import PluginOutlet from "discourse/components/plugin-outlet";
import concatClass from "discourse/helpers/concat-class";
import replaceEmoji from "discourse/helpers/replace-emoji";
import routeAction from "discourse/helpers/route-action";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
import icon from "discourse-common/helpers/d-icon";
import Creator from "./creator";
import Dates from "./dates";
Expand Down Expand Up @@ -53,9 +52,7 @@ export default class DiscoursePostEvent extends Component {
}

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

get isPublicEvent() {
Expand Down Expand Up @@ -86,7 +83,7 @@ export default class DiscoursePostEvent extends Component {
</div>
<div class="event-info">
<span class="name">
{{this.eventName}}
{{replaceEmoji this.eventName}}
</span>
<div class="status-and-creators">
<PluginOutlet
Expand Down
16 changes: 15 additions & 1 deletion spec/system/post_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
sign_in(admin)
visit "/new-topic"
end

it "safely renders html and emojis in the event name" do
post =
PostCreator.create(
admin,
title: "My test meetup event",
raw: "[event name=':cat: <script>alert(1);</script>' start='2222-02-22 00:00']\n[/event]",
)

visit(post.topic.url)

expect(page).to have_css(".event-info .name img.emoji[title='cat']")
expect(page).to have_css(".event-info .name", text: "<script>alert(1);</script>")
end

it "can create, close, and open an event" do
visit "/new-topic"
title = "My upcoming l33t event"
tomorrow = (Time.zone.now + 1.day).strftime("%Y-%m-%d")

Expand Down