Skip to content

Escape DEL and C1 control characters in client logs - #2488

Merged
kmcginnes merged 1 commit into
mainfrom
t3/escape-client-log-control-chars
Oct 28, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
t3/escape-client-log-control-chars

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

Client log text could carry DEL and C1 control characters that pino leaves raw, letting a terminal or log viewer reinterpret an entry.

User-facing: none

 app.post(CLIENT_LOG_PATH, ...)
-  logger[level]({ source: "client", clientLog: message }, "client log")
+  logger[level]({ source: "client", clientLog: escapeControlCharacters(message) }, "client log")

escapeControlCharacters in logging.ts rewrites U+007F–U+009F as \uXXXX. Pino's JSON serialization already escapes newlines and the other C0 characters, so those and backslashes are untouched. The length cap, 400 and 415 behavior are unchanged.

Evidence

Before: DEL and C1 characters reached the log entry as raw bytes.
After: app.test.ts sends U+007F, U+0080, U+0085 and U+009F and asserts \u007f, \u0080, \u0085, \u009f, plus a mixed message and a case that plain text, backslashes and newlines pass through.

Verified live: curl against a locally running proxy; no raw 0x7f or C1 bytes in the log output.

Merge Danger

Door: two-way

Impact: log text only

Related


🤖 Written by an AI agent on my behalf.

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve

@kmcginnes
kmcginnes merged commit d38ddfb into main Oct 28, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the t3/escape-client-log-control-chars branch October 28, 2026 19:53
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