mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 17:31:59 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -0,0 +1,38 @@
|
|||
import { decorateEmojis } from "@mail/utils/common/format";
|
||||
import { defineMailModels } from "@mail/../tests/mail_test_helpers";
|
||||
|
||||
import { expect, test } from "@odoo/hoot";
|
||||
import { markup } from "@odoo/owl";
|
||||
|
||||
import { makeMockEnv } from "@web/../tests/web_test_helpers";
|
||||
import { loadEmoji } from "@web/core/emoji_picker/emoji_picker";
|
||||
|
||||
const Markup = markup().constructor;
|
||||
|
||||
defineMailModels();
|
||||
|
||||
test("emojis in text content are wrapped with title and marked up", async () => {
|
||||
await makeMockEnv();
|
||||
await loadEmoji();
|
||||
const result = decorateEmojis("😇");
|
||||
expect(result).toBeInstanceOf(Markup);
|
||||
expect(result.toString()).toEqual(
|
||||
'<span class="o-mail-emoji" title=":innocent: :halo:">😇</span>'
|
||||
);
|
||||
});
|
||||
|
||||
test("emojis in attributes are not wrapped with title", async () => {
|
||||
await makeMockEnv();
|
||||
await loadEmoji();
|
||||
const result = decorateEmojis(markup`<span title='😇'>test</span>`);
|
||||
expect(result.toString()).toEqual('<span title="😇">test</span>');
|
||||
});
|
||||
|
||||
test("unsafe content is escaped when wrapping emojis with title", async () => {
|
||||
await makeMockEnv();
|
||||
await loadEmoji();
|
||||
const result = decorateEmojis("<img src='javascript:alert(\"xss\")'/>😇");
|
||||
expect(result.toString()).toEqual(
|
||||
'<img src=\'javascript:alert("xss")\'/><span class="o-mail-emoji" title=":innocent: :halo:">😇</span>'
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue