fix(matrix): detect mentions in formatted_body matrix.to links#16941
Merged
vincentkoc merged 2 commits intoopenclaw:mainfrom Feb 19, 2026
Merged
fix(matrix): detect mentions in formatted_body matrix.to links#16941vincentkoc merged 2 commits intoopenclaw:mainfrom
vincentkoc merged 2 commits intoopenclaw:mainfrom
Conversation
bfc1ccb to
f92900f
Compare
Many Matrix clients (including Element) send mentions using HTML links
in formatted_body instead of or in addition to the m.mentions field:
```json
{
"formatted_body": "<a href=\"https://matrix.to/#/@bot:matrix.org\">Bot</a>: hello",
"m.mentions": null
}
```
This change adds detection for matrix.to links in formatted_body,
supporting both plain and URL-encoded user IDs.
Changes:
- Add checkFormattedBodyMention() helper function
- Check formatted_body in resolveMentions()
- Add comprehensive test coverage
Fixes openclaw#6982
f1ccf1e to
2526acb
Compare
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
kittipond2365
pushed a commit
to kittipond2365/openclaw
that referenced
this pull request
Feb 19, 2026
…law#16941) * fix(matrix): detect mentions in formatted_body matrix.to links Many Matrix clients (including Element) send mentions using HTML links in formatted_body instead of or in addition to the m.mentions field: ```json { "formatted_body": "<a href=\"https://matrix.to/#/@bot:matrix.org\">Bot</a>: hello", "m.mentions": null } ``` This change adds detection for matrix.to links in formatted_body, supporting both plain and URL-encoded user IDs. Changes: - Add checkFormattedBodyMention() helper function - Check formatted_body in resolveMentions() - Add comprehensive test coverage Fixes openclaw#6982 * Update extensions/matrix/src/matrix/monitor/mentions.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: zerone0x <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
anschmieg
pushed a commit
to anschmieg/openclaw
that referenced
this pull request
Feb 19, 2026
…law#16941) * fix(matrix): detect mentions in formatted_body matrix.to links Many Matrix clients (including Element) send mentions using HTML links in formatted_body instead of or in addition to the m.mentions field: ```json { "formatted_body": "<a href=\"https://matrix.to/#/@bot:matrix.org\">Bot</a>: hello", "m.mentions": null } ``` This change adds detection for matrix.to links in formatted_body, supporting both plain and URL-encoded user IDs. Changes: - Add checkFormattedBodyMention() helper function - Check formatted_body in resolveMentions() - Add comprehensive test coverage Fixes openclaw#6982 * Update extensions/matrix/src/matrix/monitor/mentions.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: zerone0x <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
yneth-ray-openclaw
pushed a commit
to yneth-ray-openclaw/openclaw
that referenced
this pull request
Feb 19, 2026
…law#16941) * fix(matrix): detect mentions in formatted_body matrix.to links Many Matrix clients (including Element) send mentions using HTML links in formatted_body instead of or in addition to the m.mentions field: ```json { "formatted_body": "<a href=\"https://matrix.to/#/@bot:matrix.org\">Bot</a>: hello", "m.mentions": null } ``` This change adds detection for matrix.to links in formatted_body, supporting both plain and URL-encoded user IDs. Changes: - Add checkFormattedBodyMention() helper function - Check formatted_body in resolveMentions() - Add comprehensive test coverage Fixes openclaw#6982 * Update extensions/matrix/src/matrix/monitor/mentions.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: zerone0x <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
vignesh07
pushed a commit
to pahdo/openclaw
that referenced
this pull request
Feb 20, 2026
…law#16941) * fix(matrix): detect mentions in formatted_body matrix.to links Many Matrix clients (including Element) send mentions using HTML links in formatted_body instead of or in addition to the m.mentions field: ```json { "formatted_body": "<a href=\"https://matrix.to/#/@bot:matrix.org\">Bot</a>: hello", "m.mentions": null } ``` This change adds detection for matrix.to links in formatted_body, supporting both plain and URL-encoded user IDs. Changes: - Add checkFormattedBodyMention() helper function - Check formatted_body in resolveMentions() - Add comprehensive test coverage Fixes openclaw#6982 * Update extensions/matrix/src/matrix/monitor/mentions.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: zerone0x <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Matrix mention detection was failing when clients use
formatted_bodywithmatrix.tolinks instead of the newerm.mentionsfield.Problem
Many Matrix clients (including Element) send mentions using HTML in
formatted_body:{ "body": "Bot: hello", "formatted_body": "<a href=\\"https://matrix.to/#/@bot:matrix.org\\">Bot</a>: hello", "m.mentions": null }The
resolveMentions()function only checked:m.mentions.room- room mention flagm.mentions.user_ids- explicit user ID arraybodytextIt did NOT check
formatted_bodyformatrix.tomention links.Solution
Added
checkFormattedBodyMention()helper that:matrix.tolinks informatted_body@bot:matrix.orgvs%40bot%3Amatrix.org)Testing
Added comprehensive test coverage for:
m.mentionsfield detectionformatted_bodylink detection (plain and URL-encoded)Fixes #6982
Greptile Summary
This PR fixes Matrix mention detection when clients use
formatted_bodyHTML withmatrix.tolinks instead of (or without) the newerm.mentionsfield. A newcheckFormattedBodyMention()helper is added that parsesformatted_bodyformatrix.touser links, handling both plain and URL-encoded user IDs. The change integrates cleanly into the existingresolveMentions()flow inhandler.ts.formatted_bodydetection formatrix.tomention links alongside existingm.mentionsand regex-based detection@bot:matrix.org) and URL-encoded (%40bot%3Amatrix.org) user IDs in href attributes.fromencodeURIComponent, which could theoretically cause false-positive matchesConfidence Score: 4/5
extensions/matrix/src/matrix/monitor/mentions.ts— theencodedUserIdvariable on line 32 needs regex-special-character escaping applied.Last reviewed commit: f1ccf1e