[FIX] mail: turn tagged name with special characters into links
STEPS: * Created partner with following name: Putin's spokesman * Tag the partner in a message: @Putin's spokesman BEFORE: tag is not converted into a link AFTER: the link is created WHY: _generateMentionsLinks uses ``owl.utils.escape`` which is different from ``_.escape`` https://github.com/odoo/odoo/blob/880555b38dee0c3e3b364c19bb6b0db983bf8aa0/addons/mail/static/src/models/composer/composer.js#L659 So following replace didn't work: https://github.com/odoo/odoo/blob/880555b38dee0c3e3b364c19bb6b0db983bf8aa0/addons/mail/static/src/models/composer/composer.js#L667 --- opw-2408863 closes odoo/odoo#63056 X-original-commit: 5b62b40713d28cc905fd4c54de13cf2de39d988d Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -1169,6 +1169,48 @@ QUnit.test('Post a message containing an email address followed by a mention on
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(`Mention a partner with special character (e.g. apostrophe ')`, async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data['mail.channel'].records.push({ id: 11 });
|
||||
this.data['res.partner'].records.push({
|
||||
id: 1952,
|
||||
email: "usatyi@example.com",
|
||||
name: "Pynya's spokesman",
|
||||
});
|
||||
await this.start();
|
||||
const thread = this.env.models['mail.thread'].findFromIdentifyingData({
|
||||
id: 11,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const threadViewer = this.env.models['mail.thread_viewer'].create({
|
||||
hasThreadView: true,
|
||||
thread: [['link', thread]],
|
||||
});
|
||||
await this.createThreadViewComponent(threadViewer.threadView, { hasComposer: true });
|
||||
document.querySelector('.o_ComposerTextInput_textarea').focus();
|
||||
await afterNextRender(() => {
|
||||
["@", "P", "y", "n"].forEach((char)=>{
|
||||
document.execCommand('insertText', false, char);
|
||||
document.querySelector(`.o_ComposerTextInput_textarea`)
|
||||
.dispatchEvent(new window.KeyboardEvent('keydown'));
|
||||
document.querySelector(`.o_ComposerTextInput_textarea`)
|
||||
.dispatchEvent(new window.KeyboardEvent('keyup'));
|
||||
});
|
||||
});
|
||||
await afterNextRender(() =>
|
||||
document.querySelector('.o_ComposerSuggestion').click()
|
||||
);
|
||||
await afterNextRender(() => {
|
||||
document.querySelector('.o_Composer_buttonSend').click();
|
||||
});
|
||||
assert.containsOnce(
|
||||
document.querySelector(`.o_Message_content`),
|
||||
`.o_mail_redirect[data-oe-id="1952"][data-oe-model="res.partner"]:contains("@Pynya's spokesman")`,
|
||||
"Conversation should have a message that has been posted, which contains partner mention"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('mention 2 different partners that have the same name', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ function parseEmail(text) {
|
||||
*/
|
||||
function escapeAndCompactTextContent(content) {
|
||||
//Removing unwanted extra spaces from message
|
||||
let value = _.escape(content).trim();
|
||||
let value = owl.utils.escape(content).trim();
|
||||
value = value.replace(/(\r|\n){2,}/g, '<br/><br/>');
|
||||
value = value.replace(/(\r|\n)/g, '<br/>');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user