Skip to content

fix(outbound): keep email addresses in plain-text replies - #124249

Merged
obviyus merged 3 commits into
openclaw:mainfrom
blackorange-mega:fix/sanitize-angle-addr
Aug 16, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
blackorange-mega:fix/sanitize-angle-addr

Conversation

@blackorange-mega

@blackorange-mega blackorange-mega commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #124217

What Problem This Solves

Plain-text outbound sanitization treated an RFC 5322 angle-address such as
Support <[email protected]> as HTML and silently deleted the address before
delivery. This affects every caller of the shared sanitizer, including Telegram,
iMessage, WhatsApp, IRC, Google Chat, direct channel delivery, and the public
openclaw/plugin-sdk/channel-outbound export.

Root cause and repair

HTML_TAG_RE ended tag names at \b. Because @ follows a word character,
<[email protected]> matched as a tag and the fixpoint stripper removed it.

The shared matcher now includes the shipped XML-style . and : name
characters, then accepts only real tag-name terminators: whitespace, /, or
>. This preserves angle-address prose without adding an email parser or a
channel-specific exception. Existing HTML and namespaced-tag stripping, Google
Chat <users/...> aliases, autolinks, and internal scaffolding remain unchanged.

The iMessage final security projection explicitly mirrors this shared HTML
grammar. Its duplicate matcher is aligned in the same change so its inspection
model cannot drift from delivery sanitization.

Architectural owner: src/infra/outbound/sanitize-text.ts.

Scope

  • Shared production matcher: one-for-one functional replacement.
  • iMessage security projection mirror: one-for-one alignment.
  • Production delta: +1 net, solely the short boundary-invariant comment.
  • Tests: +25 net. Owner-boundary regressions cover address preservation,
    slash-terminated aliases, colon/dot-qualified tags, and the iMessage final
    security path.
  • No config, migration, compatibility path, dependency, or public API change.

Evidence

Pushed head: c5150a0f45418301a362b244a6ded4d98062591a.

Regression proof with the new test retained and the shared matcher reverted:

src/infra/outbound/sanitize-text.test.ts
1 failed, 48 passed
Expected: Contact us at Support <[email protected]> or reply here
Received: Contact us at Support  or reply here

Final focused test command covered the shared owner, adjacent outbound helpers,
Google Chat alias behavior, and the iMessage security projection:

Test Files  7 passed (7)
Tests       411 passed (411)
Vitest shards: unit-fast, infra, extension-imessage, extension-messaging

The compatibility regressions also failed before the final grammar repair:

shared sanitizer: 1 failed, 49 passed
Received: <vendor:note>one</vendor:note><vendor.note>two</vendor.note>
iMessage final path: 1 failed, 260 passed
Received: <vendor:note>visible</vendor:note>

Static proof:

git diff --check                                                        pass
pnpm exec oxfmt --check <4 touched files>                               pass
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json pass
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json pass
pnpm tsgo                                                               pass
pnpm tsgo:extensions                                                    pass
pnpm check:test-types                                                   pass

Distill: removed eight redundant test lines; no new abstraction or special
case. Greybeard: no attributable complexity or catastrophic-backtracking
regression; the fixed-width lookahead keeps the same asymptotic cost.

Redacted live Telegram proof

The dedicated QA user sent the changed-path prompt to a fresh exact-head Gateway
in a direct chat. The Gateway used the deterministic mock provider, then sent
the response through the real Telegram Bot API. Secrets, account ids, chat ids,
and usernames are omitted.

head: c5150a0f45418301a362b244a6ded4d98062591a
sent: Reply exactly: Contact us at Support <[email protected]> or reply here
mock provider requests: 1
recordingComplete: true
SUT events: 2 typing, 1 message, 0 edits, 0 deletions
timeline: typing at 496 ms and 1548 ms; message at 1548 ms
Bot API message id: 1255; text length: 55
observed: Contact us at Support [email protected] or reply here
gateway: sendMessage succeeded, text delivery, one chunk

The Telegram client rendered away the angle brackets, but the reported failure
was deletion of the complete address. The recipient-visible address now remains.
Artifacts: events.ndjson, summary.json, gateway.log, and one recorded mock
provider request.

Desktop GIF proof was unavailable because this exact PR head predates
scripts/e2e/telegram-desktop-recorder.ts; no unrelated recorder code was added
to the branch. The real-user TDLib event stream above is the final changed-path
proof.

ClawSweeper exact-head review

Local ClawSweeper passed on c5150a0f45418301a362b244a6ded4d98062591a:

correctness: patch is correct
findings: 0
security: 0 concerns
maintainer decision required: no
Rank-up moves: 0

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 1:58 AM ET / 05:58 UTC.

ClawSweeper review

What this changes

The PR changes shared plain-text tag matching so RFC-style angle-bracket email addresses survive outbound formatting while valid markup continues to be removed.

Regression provenance

Possible regression — probable (reproduction; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: the focused shared-sanitizer repair is correct and addresses a current silent outbound-content loss; no blocking correctness or security finding was identified.

Priority: P1
Reviewed head: c5150a0f45418301a362b244a6ded4d98062591a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with regression coverage and a real transport trace is ready for normal final-head merge verification.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies an exact-head, real Telegram Bot API trace showing the previously deleted address is recipient-visible after the shared sanitizer change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies an exact-head, real Telegram Bot API trace showing the previously deleted address is recipient-visible after the shared sanitizer change.
Evidence reviewed 7 items Current-main defect: Current main uses a word boundary after the candidate tag name; a following @ therefore makes an angle address match as removable markup.
Owner-boundary repair: The PR requires a real tag terminator after a complete HTML/XML-style name, so @ no longer qualifies while whitespace, slash, and closing-angle-bracket cases remain removable.
Static behavior check: Direct evaluation of the old and proposed expressions removes <[email protected]> only with the old matcher; both retain stripping for <vendor:note>, <vendor.note>, <users/abc>, and ordinary attributed tags.
Findings None None.
Security None None.

How this fits together

The shared outbound sanitizer converts model-produced markup into text before channel delivery and is exported to plugin channels. iMessage applies an additional final safety projection before the shared sanitizer, while Telegram, Google Chat, IRC, WhatsApp, and direct channels consume the shared result through their adapters.

flowchart LR
  A[Assistant reply] --> B[iMessage safety projection]
  A --> C[Shared plain-text sanitizer]
  B --> C
  C --> D[Channel-specific adapter]
  D --> E[Telegram and other transports]
  E --> F[Recipient-visible message]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally changes default output from a public shared sanitizer used by multiple channel adapters; verify the exact merge head preserves ordinary markup stripping and recipient-visible address delivery before landing.
  • Complete next step (P2) - This contributor PR already contains the bounded repair; no separate ClawSweeper repair job is appropriate.
Agent review details

Security

None.

PR surface

Source +10, Tests +16. Total +26 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 2 +10
Tests 1 16 0 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 28 2 +26

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +2/-1 (net +1); tests/test support +25/-0 The sole production growth is the boundary-invariant comment accompanying the matcher replacement; all remaining additions are focused owner and iMessage regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #124217
Summary: This PR is the focused candidate fix for the canonical shared-sanitizer report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Verify the shared output change on the merge head (recommended)
    Confirm the shared and iMessage sanitizer suites plus the real transport trace on the final merge head, then retain the intentional preservation of angle-address prose.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Confirm shared sanitizer, iMessage projection, and real transport address-preservation proof on the exact merge head.

Technical review

Best possible solution:

Land the shared owner-boundary grammar correction after exact merge-head verification, retaining the short invariant comment and focused regression coverage.

Do we have a high-confidence way to reproduce the issue?

Yes — current-main source and direct regex evaluation show that @ terminates the old word-boundary match and removes a normal angle-address; the PR adds the corresponding owner-boundary regression. The contributor’s packaged reproduction was not re-executed locally because this is untrusted PR code.

Is this the best way to solve the issue?

Yes — narrowing the shared tag grammar fixes the owner that every plain-text consumer uses, without an email parser or per-channel exception; the iMessage projection is kept grammar-aligned.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e49527031942.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an exact-head, real Telegram Bot API trace showing the previously deleted address is recipient-visible after the shared sanitizer change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: Current main can silently remove a contact address from replies produced through the shared plain-text outbound path.
  • merge-risk: 🚨 compatibility: The shared public sanitizer changes default text output for several channel adapters, so legitimate existing markup behavior needs final-head confirmation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Sufficient (live_output): The PR body supplies an exact-head, real Telegram Bot API trace showing the previously deleted address is recipient-visible after the shared sanitizer change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an exact-head, real Telegram Bot API trace showing the previously deleted address is recipient-visible after the shared sanitizer change.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The plain-text Telegram path changes recipient-visible chat text and is straightforward to demonstrate in Telegram.

Evidence

What I checked:

  • Current-main defect: Current main uses a word boundary after the candidate tag name; a following @ therefore makes an angle address match as removable markup. (src/infra/outbound/sanitize-text.ts:10, e49527031942)
  • Owner-boundary repair: The PR requires a real tag terminator after a complete HTML/XML-style name, so @ no longer qualifies while whitespace, slash, and closing-angle-bracket cases remain removable. (src/infra/outbound/sanitize-text.ts:11, c5150a0f4541)
  • Static behavior check: Direct evaluation of the old and proposed expressions removes <[email protected]> only with the old matcher; both retain stripping for <vendor:note>, <vendor.note>, <users/abc>, and ordinary attributed tags. (src/infra/outbound/sanitize-text.ts:11, c5150a0f4541)
  • Regression coverage: The PR adds direct owner-boundary coverage for address preservation and retains slash-terminated alias coverage. (src/infra/outbound/sanitize-text.test.ts:179, c5150a0f4541)
  • Caller and sibling coverage: iMessage runs its final projection before the shared sanitizer, and the PR aligns its projection grammar; Telegram, Google Chat, IRC, WhatsApp, and direct plugin delivery also consume the shared sanitizer. (extensions/imessage/src/channel.ts:430, e49527031942)
  • Real transport proof: The PR body records exact-head c5150a0 Telegram Bot API delivery through a real transport with the recipient-visible email address retained; its deterministic mock provider is appropriate because the repaired boundary is post-provider text sanitization. (c5150a0f4541)

Likely related people:

  • Peter Steinberger: Current-main blame assigns the shared matcher and the mirrored iMessage projection to the latest rewrite commit. (role: recent source-line owner; confidence: medium; commits: e68f3d8ad190; files: src/infra/outbound/sanitize-text.ts, extensions/imessage/src/monitor/sanitize-outbound.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Reconfirm the shared sanitizer and iMessage projection evidence on the exact merge head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-15T19:21:18.020Z sha fdf42400fd2796fcea1c414b35af98095e56b58d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T21:01:20.392Z sha fdf42400fd2796fcea1c414b35af98095e56b58d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T21:41:37.332Z sha c56395f :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Aug 15, 2026
The generic HTML tag matcher ended the tag name at a word boundary, so an
RFC 5322 angle-addr such as `Support <[email protected]>` matched as a
tag and was deleted before send, with no warning and no marker.

A tag name ends at whitespace, `/`, or `>`. Requiring that boundary keeps
real markup, Google Chat `<users/...>` aliases, and runtime scaffolding
stripping, and leaves `<local@domain>` in prose alone. The sibling
patterns in this module already gate on the same boundary.

Closes #124217
@blackorange-mega

Copy link
Copy Markdown
Contributor Author

Rebased onto main and applied the Rank-up moves item from the latest review.

"Confirm focused sanitizer validation on the exact merge or rebased head." — done. Head is now c56395f79, rebased onto 73c45824e (branch was 17 commits behind). The rebase is a mechanical refresh; the diff is unchanged by it — production +1 net (2 added, 1 removed), tests +18.

The regression test still fails on pre-fix source at this base (production change reverted, new tests kept):

 × preserves angle-addr email addresses
AssertionError: expected 'Contact us at Support  or reply here'
              to be 'Contact us at Support <[email protected]> or reply here'
 Tests  1 failed | 48 passed (49)

Focused and sibling outbound suites on the rebased head, all green:

src/infra/outbound/sanitize-text.test.ts                 49 passed (49)
src/infra/outbound/markdown-details.test.ts              14 passed (14)
src/infra/outbound/payloads.test.ts                      43 passed (43)
src/infra/outbound/deliver-payload.presentation.test.ts   3 passed (3)
src/infra/outbound/format.test.ts                         9 passed (9)

On mantis: telegram-visible-proof: the Mantis capture command is maintainer-triggered, so I have not posted it. If the terminal proof above is not enough for the changed path, I can add a mock-gateway harness run instead.

@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 16, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 16, 2026
@obviyus obviyus self-assigned this Aug 16, 2026
@obviyus
obviyus enabled auto-merge (squash) August 16, 2026 05:55
@obviyus
obviyus merged commit 292ea7a into openclaw:main Aug 16, 2026
191 of 196 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…penclaw#124249)

Preserve RFC 5322 angle-address emails without weakening namespaced tag stripping, and keep the iMessage security projection aligned.

Co-authored-by: Aria Ghasedi <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sanitizeForPlainText deletes RFC 5322 angle-addr email addresses (Name <[email protected]>) from outbound plain-text replies

2 participants