escape regex characters in mentions #209

Merged
merged 1 commit into from Feb 5, 2013

Conversation

Projects
None yet
2 participants
@Ibuprofen
Contributor

Ibuprofen commented Feb 4, 2013

Usernames containing regular expression characters break formatting. Should mentions match anywhere or only at the beginning of the line?

escape regex characters
Usernames containing regular expression characters break formatting
@thedjpetersen

This comment has been minimized.

Show comment Hide comment
@thedjpetersen

thedjpetersen Feb 4, 2013

Owner

Mentions should match anywhere.

Owner

thedjpetersen commented Feb 4, 2013

Mentions should match anywhere.

@@ -61,7 +61,10 @@ window.utils = {
},
mentions: function(text) {
- var re = new RegExp('\\b' + irc.me.get('nick') + '\\b', 'g');
+ var escape = function(text) {

This comment has been minimized.

Show comment Hide comment
@thedjpetersen

thedjpetersen Feb 4, 2013

Owner

Do you need this function or could the underscore escape function work? http://underscorejs.org/#escape

@thedjpetersen

thedjpetersen Feb 4, 2013

Owner

Do you need this function or could the underscore escape function work? http://underscorejs.org/#escape

@Ibuprofen

This comment has been minimized.

Show comment Hide comment
@Ibuprofen

Ibuprofen Feb 4, 2013

Contributor

No that function is to convert characters into their html equivalents. An example is & to & The bug I ran into is when a username contains one of the regex characters like the pipe (|) that will be passed into the expression without escaping and then alter the expression.

Contributor

Ibuprofen commented Feb 4, 2013

No that function is to convert characters into their html equivalents. An example is & to & The bug I ran into is when a username contains one of the regex characters like the pipe (|) that will be passed into the expression without escaping and then alter the expression.

thedjpetersen added a commit that referenced this pull request Feb 5, 2013

Merge pull request #209 from Ibuprofen/patch-1
escape regex characters in mentions

@thedjpetersen thedjpetersen merged commit 9c8e133 into thedjpetersen:master Feb 5, 2013

@thedjpetersen

This comment has been minimized.

Show comment Hide comment
@thedjpetersen

thedjpetersen Feb 5, 2013

Owner

Thanks!

Owner

thedjpetersen commented Feb 5, 2013

Thanks!

@Ibuprofen Ibuprofen deleted the Ibuprofen:patch-1 branch Feb 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment