diff --git a/lib/pushprocessor.js b/lib/pushprocessor.js index 95a90a99b..c6774f318 100644 --- a/lib/pushprocessor.js +++ b/lib/pushprocessor.js @@ -160,7 +160,9 @@ function PushProcessor(client) { var displayName = room.currentState.getMember(client.credentials.userId).name; - var pat = new RegExp("\\b" + escapeRegExp(displayName) + "\\b", 'i'); + // N.B. we can't use \b as it chokes on unicode. however \W seems to be okay + // as shorthand for [^0-9A-Za-z_]. + var pat = new RegExp("(^|\\W)" + escapeRegExp(displayName) + "(\\W|$)", 'i'); return ev.content.body.search(pat) > -1; }; @@ -174,7 +176,7 @@ function PushProcessor(client) { var pat; if (cond.key == 'content.body') { - pat = '\\b' + globToRegexp(cond.pattern) + '\\b'; + pat = '(^|\\W)' + globToRegexp(cond.pattern) + '(\\W|$)'; } else { pat = '^' + globToRegexp(cond.pattern) + '$'; }