mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
rendered_markdown: Fix HTML injection bug in update_elements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e1029b59ed
commit
4dc27216f4
@@ -323,9 +323,13 @@ export const update_elements = ($content: JQuery): void => {
|
||||
// Display emoji (including realm emoji) as text if
|
||||
// user_settings.emojiset is 'text'.
|
||||
if (user_settings.emojiset === "text") {
|
||||
$content.find(".emoji").replaceWith(function (): string {
|
||||
$content
|
||||
.find(".emoji")
|
||||
.text(function () {
|
||||
const text = $(this).attr("title");
|
||||
return ":" + text + ":";
|
||||
});
|
||||
})
|
||||
.contents()
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -467,10 +467,11 @@ run_test("emoji", () => {
|
||||
const $emoji = $.create("emoji-stub");
|
||||
$emoji.attr("title", "tada");
|
||||
let called = false;
|
||||
$emoji.replaceWith = (f) => {
|
||||
$emoji.text = (f) => {
|
||||
const text = f.call($emoji);
|
||||
assert.equal(":tada:", text);
|
||||
called = true;
|
||||
return {contents: () => ({unwrap() {}})};
|
||||
};
|
||||
$content.set_find_results(".emoji", $emoji);
|
||||
user_settings.emojiset = "text";
|
||||
|
||||
Reference in New Issue
Block a user