mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:01:23 +00:00
fix(whatsapp): preserve outbound document filenames (#15594)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 8e0d765d1d
Co-authored-by: TsekaLuk <79151285+TsekaLuk@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Reviewed-by: @steipete
This commit is contained in:
@@ -19,15 +19,29 @@ import { attachGatewayWsMessageHandler } from "./ws-connection/message-handler.j
|
||||
type SubsystemLogger = ReturnType<typeof createSubsystemLogger>;
|
||||
|
||||
const LOG_HEADER_MAX_LEN = 300;
|
||||
const LOG_HEADER_CONTROL_REGEX = /[\u0000-\u001f\u007f-\u009f]/g;
|
||||
const LOG_HEADER_FORMAT_REGEX = /\p{Cf}/gu;
|
||||
|
||||
function replaceControlChars(value: string): string {
|
||||
let cleaned = "";
|
||||
for (const char of value) {
|
||||
const codePoint = char.codePointAt(0);
|
||||
if (
|
||||
codePoint !== undefined &&
|
||||
(codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f))
|
||||
) {
|
||||
cleaned += " ";
|
||||
continue;
|
||||
}
|
||||
cleaned += char;
|
||||
}
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
const sanitizeLogValue = (value: string | undefined): string | undefined => {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
const cleaned = value
|
||||
.replace(LOG_HEADER_CONTROL_REGEX, " ")
|
||||
const cleaned = replaceControlChars(value)
|
||||
.replace(LOG_HEADER_FORMAT_REGEX, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
Reference in New Issue
Block a user