From dbe0337555a496d3fa925498b5a8b78d6c3d292e Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 28 Nov 2018 11:13:19 +0000 Subject: [PATCH] [FIX] mail: mention escape let original intact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When selecting a mention we will add a mention in a list of selection from the list of mention. In 10f0766b3 that mention in list of selection was escaped so this would match the text that would be escaped when the mention was searched in it. But the object are the same so the change modified the original list. Modified test failed with: ``` 10. first partner mention should still display the correct partner name (Expected: "ЅpëciãlUser<&>\"`' ツ" Result: "ЅpëciãlUser<&>\"`' <&>"`' ツ") ``` opw-1909300 closes #29098 --- addons/mail/static/src/js/composers/mention_manager.js | 4 ++-- addons/mail/static/tests/discuss_tests.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/composers/mention_manager.js b/addons/mail/static/src/js/composers/mention_manager.js index 7acecadc062..907263328cc 100644 --- a/addons/mail/static/src/js/composers/mention_manager.js +++ b/addons/mail/static/src/js/composers/mention_manager.js @@ -378,9 +378,9 @@ var MentionManager = Widget.extend({ var textInput = this._composer.$input.val(); var id = $(ev.currentTarget).data('id'); var suggestions = _.flatten(this.get('mention_suggestions')); - var selectedSuggestion = _.find(suggestions, function (s) { + var selectedSuggestion = _.clone(_.find(suggestions, function (s) { return s.id === id; - }); + })); var substitution = selectedSuggestion.substitution; if (!substitution) { // no substitution string given, so use the mention name instead diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index 9913435363c..c676a805823 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -424,7 +424,7 @@ QUnit.test('@ mention in channel', function (assert) { }); QUnit.test('@ mention with special chars', function (assert) { - assert.expect(9); + assert.expect(10); var done = assert.async(); var fetchListenersDef = $.Deferred(); var receiveMessageDef = $.Deferred(); @@ -506,6 +506,12 @@ QUnit.test('@ mention with special chars', function (assert) { assert.strictEqual(discuss.$('.o_thread_message_content a').text(), "@\u0405pëciãlUser<&>\"`' \u30C4", "should have correct mention link in the message content"); + $input.val("@"); + $input.trigger('keyup'); + var $mention = discuss.$('.o_mention_proposition'); + assert.strictEqual($mention.find('.o_mention_name').text(), + '\u0405pëciãlUser<&>"`\' \u30C4', + "first partner mention should still display the correct partner name"); discuss.destroy(); done(); });