Skip to content

fix(markdown): require paired || delimiters for spoiler detection#26105

Merged
steipete merged 2 commits intoopenclaw:mainfrom
Sid-Qin:fix/telegram-spoiler-pipe-26068
Feb 25, 2026
Merged

fix(markdown): require paired || delimiters for spoiler detection#26105
steipete merged 2 commits intoopenclaw:mainfrom
Sid-Qin:fix/telegram-spoiler-pipe-26068

Conversation

@Sid-Qin
Copy link
Contributor

@Sid-Qin Sid-Qin commented Feb 25, 2026

Summary

  • Problem: Telegram renders single | pipe characters (e.g., emoticons like ( ̄_ ̄|)) and unpaired || as spoiler/hidden text, hiding subsequent message content
  • Why it matters: Users see garbled messages with unexpectedly hidden text in Telegram
  • What changed: Added a pre-scan in injectSpoilersIntoInline (src/markdown/ir.ts) that counts all || delimiters across an inline token group; if the count is odd or < 2, spoiler injection is skipped entirely. Handles cross-token || pairs correctly (e.g., ||**bold**||)
  • What did NOT change: Properly paired ||spoiler|| syntax continues to work as expected

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

Single | and unpaired || in messages are now rendered as plain text in Telegram instead of being incorrectly treated as spoiler markers.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • Integration/channel: Telegram

Steps

  1. Send a message containing ( ̄_ ̄|) face or before || after to the bot
  2. View the message in Telegram client

Expected

  • | and unpaired || display as plain text

Actual (before fix)

  • Text after | appears as spoiler (gray hidden block)

Evidence

  • Failing test/log before + passing after
  • New test: single pipe ( ̄_ ̄|) not treated as spoiler
  • New test: unpaired before || after not treated as spoiler
  • Existing tests: paired ||spoiler|| and ||**bold**|| still render correctly
  • All 69 markdown/telegram format tests pass

Human Verification (required)

  • Verified scenarios: single pipe, unpaired ||, paired ||, nested formatting inside spoilers
  • Edge cases checked: odd delimiter count, cross-token delimiter pairs, empty inline groups
  • What you did not verify: live Telegram bot end-to-end (unit tests only)

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the single commit afc7168
  • Files/config to restore: src/markdown/ir.ts
  • Known bad symptoms reviewers should watch for: Legitimate ||spoiler|| syntax no longer rendering as spoilers

Risks and Mitigations

  • Risk: Edge case where || delimiters are split across inline groups in unusual markdown structures
    • Mitigation: Pre-scan counts across all text tokens within the same inline group; tested with nested formatting

SidQin-cyber and others added 2 commits February 25, 2026 04:53
An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>
@steipete steipete force-pushed the fix/telegram-spoiler-pipe-26068 branch from afc7168 to 2c84a2a Compare February 25, 2026 04:54
@steipete steipete merged commit 2e84017 into openclaw:main Feb 25, 2026
9 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm test src/telegram/format.test.ts && pnpm check
  • Land commit: 2c84a2a
  • Merge commit: 2e84017

Thanks @Sid-Qin!

steipete added a commit to justinhuangcode/openclaw that referenced this pull request Feb 25, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
Jackson3195 pushed a commit to Jackson3195/openclaw-with-a-personal-touch that referenced this pull request Feb 25, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
…enclaw#26105)

* fix(markdown): require paired || delimiters for spoiler detection

An unpaired || (odd count across all inline tokens) would open a
spoiler that never closes, causing closeRemainingStyles to extend it
to the end of the text. This made all content after an unpaired ||
appear as hidden/spoiler in Telegram.

Pre-count || delimiters across the entire inline token group and skip
spoiler injection entirely when the count is less than 2 or odd. This
prevents single | characters and unpaired || from triggering spoiler
formatting.

Closes openclaw#26068

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: preserve valid spoiler pairs with trailing unmatched delimiters (openclaw#26105) (thanks @Sid-Qin)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram channel incorrectly treats "|" pipe character as spoiler/hidden text

2 participants