mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +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
|
// Display emoji (including realm emoji) as text if
|
||||||
// user_settings.emojiset is 'text'.
|
// user_settings.emojiset is 'text'.
|
||||||
if (user_settings.emojiset === "text") {
|
if (user_settings.emojiset === "text") {
|
||||||
$content.find(".emoji").replaceWith(function (): string {
|
$content
|
||||||
|
.find(".emoji")
|
||||||
|
.text(function () {
|
||||||
const text = $(this).attr("title");
|
const text = $(this).attr("title");
|
||||||
return ":" + text + ":";
|
return ":" + text + ":";
|
||||||
});
|
})
|
||||||
|
.contents()
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -467,10 +467,11 @@ run_test("emoji", () => {
|
|||||||
const $emoji = $.create("emoji-stub");
|
const $emoji = $.create("emoji-stub");
|
||||||
$emoji.attr("title", "tada");
|
$emoji.attr("title", "tada");
|
||||||
let called = false;
|
let called = false;
|
||||||
$emoji.replaceWith = (f) => {
|
$emoji.text = (f) => {
|
||||||
const text = f.call($emoji);
|
const text = f.call($emoji);
|
||||||
assert.equal(":tada:", text);
|
assert.equal(":tada:", text);
|
||||||
called = true;
|
called = true;
|
||||||
|
return {contents: () => ({unwrap() {}})};
|
||||||
};
|
};
|
||||||
$content.set_find_results(".emoji", $emoji);
|
$content.set_find_results(".emoji", $emoji);
|
||||||
user_settings.emojiset = "text";
|
user_settings.emojiset = "text";
|
||||||
|
|||||||
Reference in New Issue
Block a user