fix(python/robomp): updated mention regex to correctly reject suffixes
- Updated the mention extraction regex to prevent partial matching when a suffix follows the `[bot]` identifier. - Added a regression test to ensure that invalid extended suffixes are correctly rejected.
This commit is contained in:
@@ -153,7 +153,7 @@ def extract_mention(body: str | None, bot_login: str) -> str | None:
|
||||
if not login:
|
||||
return None
|
||||
pattern = re.compile(
|
||||
rf"(?<![A-Za-z0-9_-])@{re.escape(login)}(?:\[bot\])?(?![A-Za-z0-9_-])",
|
||||
rf"(?<![A-Za-z0-9_-])@{re.escape(login)}(?:\[bot\](?![A-Za-z0-9_-])|(?![A-Za-z0-9_\[-]))",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if not pattern.search(body):
|
||||
|
||||
Reference in New Issue
Block a user