fix(webui): export logs without terminal control codes

Keep terminal styling confined to interactive console output while storing plain structured log lines for subscribers and file persistence.

Sanitize downloads again at the WebUI boundary so cached legacy entries and fallback-formatted records cannot leak CSI, OSC, DCS, or C1 control sequences. Add regression coverage for colored output, hyperlinks, control strings, malformed sequences, and preserved multiline text.
This commit is contained in:
DrSmoothl committed 2026-07-16 19:20:48 +08:00
1 parent f581fab396
commit 0503af2fcc
9 files changed
+136 -17

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
import { format } from 'util';
import { getFileTransport } from './log-file-transport';
import { sanitizeLogLine } from './log-sanitize';
import { currentRequestId } from './request-context';
type LogLevel = 'trace' | 'debug' | 'info' | 'success' | 'warn' | 'error';
@@ -212,7 +213,7 @@ function emit(level: LogLevel, options: LogOptions, args: unknown[]): void {
...(options.uin !== undefined ? { uin: options.uin } : {}),
...(reqId !== undefined ? { req: reqId } : {}),
message,
line,
line: sanitizeLogLine(line),
};
if (passesConsole) {