Problem
The EventBus.matchesPattern() method in src/core/EventBus.js:171-173 only escapes the * wildcard character but does not escape other regex metacharacters. This causes unintended pattern matches.
Affected Code
// EventBus.js:171-173
matchesPattern(eventName, pattern) {
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
return regex.test(eventName);
}
Issue
A pattern like event.add would incorrectly match event_add, eventXadd, etc. because the . character is treated as a regex wildcard (matching any character) rather than a literal dot.
Metacharacters that should be escaped: ., +, ?, (, ), [, ], {, }, |, ^, $, \
Expected Behavior
Only the * character should act as a wildcard. All other special regex characters should be treated as literals.
Solution
Escape all regex metacharacters except * before building the RegExp, or use a regex escape utility.
Problem
The
EventBus.matchesPattern()method insrc/core/EventBus.js:171-173only escapes the*wildcard character but does not escape other regex metacharacters. This causes unintended pattern matches.Affected Code
Issue
A pattern like
event.addwould incorrectly matchevent_add,eventXadd, etc. because the.character is treated as a regex wildcard (matching any character) rather than a literal dot.Metacharacters that should be escaped:
.,+,?,(,),[,],{,},|,^,$,\Expected Behavior
Only the
*character should act as a wildcard. All other special regex characters should be treated as literals.Solution
Escape all regex metacharacters except
*before building the RegExp, or use a regex escape utility.