Telegram inline-markdown stripper eats underscores and asterisks inside identifiers #1201

Closed
opened 2026-10-27 13:39:25 +00:00 by sam · 0 comments
Owner

internal/channels/telegram/richblocks.go:21-22 define italicBlockMark = \*(.+?)\* and italicBlockUndersc = _(.+?)_. stripInlineMarkdown applies them to every paragraph, heading, list item and quote. Neither honours CommonMark's rule that intraword underscores do not open emphasis, and neither requires the delimiter to be left/right-flanking.

Any two underscores on one line are treated as an italic span and deleted. Reproduced verbatim:

in : "allow_concurrent": true, "max_retries": true, "review_enabled": true
out: "allowconcurrent": true, "maxretries": true, "review_enabled": true

in : the internal/webui/config_schema_test.go file
out: the internal/webui/configschematest.go file

Same defect for asterisks, which matters because this project's prose is full of Go pointer types:

in : RecordDispatch takes no *sql.Tx and returns *Result
out: RecordDispatch takes no sql.Tx and returns Result

Effect: every agent report relayed to Telegram silently corrupts snake_case identifiers, file paths and pointer types, so operators are handed citations to files that do not exist. Observed 2026-09-12 in a relayed investigation report.

Fix: require the opening delimiter to be preceded by start-of-line, whitespace or punctuation and the closing one to be followed by end-of-line, whitespace or punctuation, so intraword runs are left alone.

Acceptance criteria

Table-driven tests prove snake_case identifiers, dotted paths and Go pointer types survive stripInlineMarkdown unchanged, while genuine emphasis and emphasis are still reduced to plain text.

Notes

WIDENED (2026-09-12): closeCode calls stripInlineMarkdown on fenced code content too (richblocks.go, closeCode). Verbatim code is therefore also corrupted. Proven: a fenced Go block containing 'func f(tx *sql.Tx) *Result' renders as 'func f(tx sql.Tx) Result'. Underscores survive inside fences only because Go regexp '.' does not cross newlines, so a same-line pair is still eaten. Fix must also stop stripping inside preformatted blocks: code is verbatim by definition.

Close reason

Closed


Imported from beads archie-core-8x1r · GitHub #801 · type bug · priority P1 · created 2026-09-11 · closed 2026-09-11

internal/channels/telegram/richblocks.go:21-22 define italicBlockMark = `\*(.+?)\*` and italicBlockUndersc = `_(.+?)_`. stripInlineMarkdown applies them to every paragraph, heading, list item and quote. Neither honours CommonMark's rule that intraword underscores do not open emphasis, and neither requires the delimiter to be left/right-flanking. Any two underscores on one line are treated as an italic span and deleted. Reproduced verbatim: in : "allow_concurrent": true, "max_retries": true, "review_enabled": true out: "allowconcurrent": true, "maxretries": true, "review_enabled": true in : the internal/webui/config_schema_test.go file out: the internal/webui/configschematest.go file Same defect for asterisks, which matters because this project's prose is full of Go pointer types: in : RecordDispatch takes no *sql.Tx and returns *Result out: RecordDispatch takes no sql.Tx and returns Result Effect: every agent report relayed to Telegram silently corrupts snake_case identifiers, file paths and pointer types, so operators are handed citations to files that do not exist. Observed 2026-09-12 in a relayed investigation report. Fix: require the opening delimiter to be preceded by start-of-line, whitespace or punctuation and the closing one to be followed by end-of-line, whitespace or punctuation, so intraword runs are left alone. ### Acceptance criteria Table-driven tests prove snake_case identifiers, dotted paths and Go pointer types survive stripInlineMarkdown unchanged, while genuine _emphasis_ and *emphasis* are still reduced to plain text. ### Notes WIDENED (2026-09-12): closeCode calls stripInlineMarkdown on fenced code content too (richblocks.go, closeCode). Verbatim code is therefore also corrupted. Proven: a fenced Go block containing 'func f(tx *sql.Tx) *Result' renders as 'func f(tx sql.Tx) Result'. Underscores survive inside fences only because Go regexp '.' does not cross newlines, so a same-line pair is still eaten. Fix must also stop stripping inside preformatted blocks: code is verbatim by definition. ### Close reason Closed --- _Imported from beads `archie-core-8x1r` · GitHub #801 · type bug · priority P1 · created 2026-09-11 · closed 2026-09-11_
sam added the highbug labels 2026-10-27 13:39:25 +00:00
sam self-assigned this 2026-10-27 13:39:25 +00:00
sam closed this issue 2026-10-27 13:39:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1201