Skip to content

server: scrub nul characters from thread titles, notion task text and translations - #195

Merged
morajabi merged 1 commit into
mainfrom
claude/server-nul-outward-text
Dec 1, 2026
Merged

morajabi merged 1 commit into
mainfrom
claude/server-nul-outward-text

Conversation

@morajabi

Copy link
Copy Markdown
Contributor

This finishes a gap left by the 2026-11-06 NUL text fix ("Not covered by the server fix"). displayMessageText scrubs NUL characters from message text when messages are encoded, but some text left the server through other paths without it:

  • Reply-thread default titles: built from decrypted anchor text in subthreads.ts (both the current and legacy builders). isDefaultReplyThreadTitle scrubs the stored title too, so titles saved earlier with a raw NUL still count as defaults.
  • Notion task notification text (taskNotificationText.ts).
  • Translations, input and output:
    • Message and context text are scrubbed after decryption, before they go to the provider, and restoreCodeTrailingNewlines compares against the same scrubbed text.
    • Both translation encoders scrub their output, which also covers translations already stored with a NUL.

displayMessageText replaces NUL with U+FFFD, which has the same UTF-16 length, so entity offsets don't move. It gains a string | null overload.

Not covered: thread titles a person sets themselves are still not scrubbed when chats are encoded.

Tests

  • 4 new NUL cases (subthreads, notion, translation input, translation output). All 4 fail with the old code.
  • The 4 changed test files plus encodeMessage.test.ts: 32 pass.
  • A wider run of 62 files across subthreads, transcript, translation and notion passes, except mcpReadCost.test.ts › archive pass stays within its statement budget, which fails the same way on an unrelated branch.
  • typecheck, test:check and lint:strict are clean.

🤖 Generated with Claude Code

… translations

Reply-thread default titles, Notion task notification text, text sent to the translation provider and translations sent to clients now show NUL as U+FFFD via displayMessageText. The replacement is one UTF-16 unit, so entity offsets stay valid. Placeholder detection scrubs the stored title too, so titles stored with a raw NUL still classify as defaults.
@morajabi
morajabi force-pushed the claude/server-nul-outward-text branch from 0744e98 to 02ee206 Compare December 1, 2026 10:19
@morajabi
morajabi merged commit 84c173c into main Dec 1, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant