Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Mention replacement can occur recursively #10

Open
ProLoser opened this issue Aug 12, 2015 · 2 comments
Open

Mention replacement can occur recursively #10

ProLoser opened this issue Aug 12, 2015 · 2 comments

Comments

@ProLoser
Copy link
Member

Due to how the mentions of someone's names may occur, there is a chance that the rendering may parse mentions recursively. For example, if you replace @mentions with mentions then try to highlight that, yet the code is @[mentions] then you may end up replacing things over and over.

@NamPNQ
Copy link
Contributor

NamPNQ commented Jun 16, 2016

We have two method to slove this:

  1. return value of function label could be not contain return value encode
  2. use replace by regex instead String.prototype.replace in ngModel.$parsers.push...

@peacepostman
Copy link

Hello for those looking for a solution we used this snippet :

var regex = new RegExp("(?<![\\w])"+_this.label(mention)+"(?![\\w])", 'g');
return value = value.replace(regex, _this.encode(mention));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants