mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: XSS in bookmarks list (#13311)
We should use `fancy_title` instead of `title` when displaying a topic title to ensure only the allowed html is not escaped.
This commit is contained in:
parent
6759e5e396
commit
3477c8a2a9
@ -3,17 +3,20 @@ import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
|
||||
registerUnbound("topic-link", (topic, args) => {
|
||||
const title = topic.get("fancyTitle");
|
||||
|
||||
const url = topic.linked_post_number
|
||||
? topic.urlForPostNumber(topic.linked_post_number)
|
||||
: topic.get("lastUnreadUrl");
|
||||
|
||||
const classes = ["title"];
|
||||
|
||||
if (args.class) {
|
||||
args.class.split(" ").forEach((c) => classes.push(c));
|
||||
}
|
||||
|
||||
const result = `<a href='${url}'
|
||||
class='${classes.join(" ")}'
|
||||
data-topic-id='${topic.id}'>${title}</a>`;
|
||||
return htmlSafe(result);
|
||||
return htmlSafe(
|
||||
`<a href='${url}'
|
||||
class='${classes.join(" ")}'
|
||||
data-topic-id='${topic.id}'>${title}</a>`
|
||||
);
|
||||
});
|
||||
|
@ -125,13 +125,9 @@ const Bookmark = RestModel.extend({
|
||||
).capitalize();
|
||||
},
|
||||
|
||||
@discourseComputed("linked_post_number", "title", "topic_id")
|
||||
topicLink(linked_post_number, title, topic_id) {
|
||||
return Topic.create({
|
||||
id: topic_id,
|
||||
fancy_title: title,
|
||||
linked_post_number,
|
||||
});
|
||||
@discourseComputed("linked_post_number", "fancy_title", "topic_id")
|
||||
topicLink(linked_post_number, fancy_title, id) {
|
||||
return Topic.create({ id, fancy_title, linked_post_number });
|
||||
},
|
||||
|
||||
loadItems(params) {
|
||||
|
@ -16,6 +16,7 @@ class UserBookmarkSerializer < ApplicationSerializer
|
||||
:reminder_at,
|
||||
:pinned,
|
||||
:title,
|
||||
:fancy_title,
|
||||
:deleted,
|
||||
:hidden,
|
||||
:category_id,
|
||||
@ -53,6 +54,10 @@ class UserBookmarkSerializer < ApplicationSerializer
|
||||
topic.title
|
||||
end
|
||||
|
||||
def fancy_title
|
||||
topic.fancy_title
|
||||
end
|
||||
|
||||
def deleted
|
||||
topic.deleted_at.present? || post.deleted_at.present?
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user