openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 602 B
JavaScript
//!src/gateway/chat-input-sanitize.ts
const DISALLOWED_CHAT_CONTROL_RANGE=`${String.fromCharCode(0)}-${String.fromCharCode(8)}${String.fromCharCode(11)}${String.fromCharCode(12)}${String.fromCharCode(14)}-${String.fromCharCode(31)}${String.fromCharCode(127)}`;const DISALLOWED_CHAT_CONTROL_RE=new RegExp(`[${DISALLOWED_CHAT_CONTROL_RANGE}]`,`g`);function sanitizeChatSendMessageInput(e){const t=e.normalize(`NFC`);if(t.includes(`\0`))return{ok:false,error:`message must not contain null bytes`};return{ok:true,message:t.replace(DISALLOWED_CHAT_CONTROL_RE,``)}}export{sanitizeChatSendMessageInput as t};