You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
workaround for unicode regexp matches - https://github.com/vector-im/vector-web/issues/568
This commit is contained in:
@@ -160,7 +160,9 @@ function PushProcessor(client) {
|
|||||||
|
|
||||||
var displayName = room.currentState.getMember(client.credentials.userId).name;
|
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;
|
return ev.content.body.search(pat) > -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,7 +176,7 @@ function PushProcessor(client) {
|
|||||||
|
|
||||||
var pat;
|
var pat;
|
||||||
if (cond.key == 'content.body') {
|
if (cond.key == 'content.body') {
|
||||||
pat = '\\b' + globToRegexp(cond.pattern) + '\\b';
|
pat = '(^|\\W)' + globToRegexp(cond.pattern) + '(\\W|$)';
|
||||||
} else {
|
} else {
|
||||||
pat = '^' + globToRegexp(cond.pattern) + '$';
|
pat = '^' + globToRegexp(cond.pattern) + '$';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user