You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function updateValues() {
var syntaxMessage = getInputBoxValue(); //Get the actual value of the text area
_.each(mentionsCollection, function (mention) {
var textSyntax = settings.templates.mentionItemSyntax(mention);
syntaxMessage = syntaxMessage.replace(new RegExp(utils.regexpEncode(mention.value), 'g'), textSyntax);
});
var mentionText = utils.htmlEncode(syntaxMessage); //Encode the syntaxMessage
_.each(mentionsCollection, function (mention) {
var formattedMention = _.extend({}, mention, {value: utils.htmlEncode(mention.value)});
var textSyntax = settings.templates.mentionItemSyntax(formattedMention);
var textHighlight = settings.templates.mentionItemHighlight(formattedMention);
mentionText = mentionText.replace(new RegExp(utils.regexpEncode(textSyntax), 'g'), textHighlight);
});
mentionText = mentionText.replace(/\n/g, '<br />'); //Replace the escape character for <br />
mentionText = mentionText.replace(/ {2}/g, ' '); //Replace the 2 preceding token to
elmInputBox.data('messageText', syntaxMessage); //Save the messageText to elmInputBox
elmInputBox.trigger('updated');
elmMentionsOverlay.find('div').html(mentionText); //Insert into a div of the elmMentionsOverlay the mention text
}
The text was updated successfully, but these errors were encountered:
karthifairhawn
changed the title
There is a problem when mention username contains $& in it.
There is a problem when mentioned username contains $& in it.
Apr 18, 2023
MentionsInput.updateValues()
As per text.replace() -- MDN
When the mentioning username contains the value
$&
in it, It will be replaced by the username itself again which leads to wrong username value.Input Username
He
$&
lloUsername Constructed after Regex Manipulation
He
He$&llo
lloThe text was updated successfully, but these errors were encountered: