[FIX] mail: mention special char=>link partner

This is a regression from: 10f0766b3. In it the visual side was solved,
but unexpectedly the functional side still worked on unescaped content.

Thus visually a @partnèr could be seen as a link, but it was no anymore
added as follower.

Without change, modified test fails with:

 mentioned partners are sent to server (expected: [1], result: [])

note: change is partial backport of 12.2 e2f20ffa9

opw-1931247
closes #30846
This commit is contained in:
Nicolas Lempereur
2019-02-05 17:24:19 +00:00
parent dcd79a543a
commit d730f66964
2 changed files with 6 additions and 5 deletions
@@ -52,10 +52,8 @@ var MentionManager = Widget.extend({
getListenerSelection: function (delimiter) {
var listener = _.findWhere(this._listeners, { delimiter: delimiter });
if (listener) {
var inputMentions = this._composer
.$input
.val()
.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
var escapedVal = _.escape(this._composer.$input.val());
var inputMentions = escapedVal.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
return this._validateSelection(listener.selection, inputMentions);
}
return [];
+4 -1
View File
@@ -424,7 +424,7 @@ QUnit.test('@ mention in channel', function (assert) {
});
QUnit.test('@ mention with special chars', function (assert) {
assert.expect(10);
assert.expect(11);
var done = assert.async();
var fetchListenersDef = $.Deferred();
var receiveMessageDef = $.Deferred();
@@ -452,6 +452,9 @@ QUnit.test('@ mention with special chars', function (assert) {
]);
}
if (args.method === 'message_post') {
assert.deepEqual(args.kwargs.partner_ids, [1],
"mentioned partners are sent to server"
)
var data = {
author_id: ["42", "Me"],
body: args.kwargs.body,