( serverName: string, content: string, meta?: Record<string, string>, )
| 104 | const SAFE_META_KEY = /^[a-zA-Z_][a-zA-Z0-9_]*$/ |
| 105 | |
| 106 | export function wrapChannelMessage( |
| 107 | serverName: string, |
| 108 | content: string, |
| 109 | meta?: Record<string, string>, |
| 110 | ): string { |
| 111 | const attrs = Object.entries(meta ?? {}) |
| 112 | .filter(([k]) => SAFE_META_KEY.test(k)) |
| 113 | .map(([k, v]) => ` ${k}="${escapeXmlAttr(v)}"`) |
| 114 | .join('') |
| 115 | return `<${CHANNEL_TAG} source="${escapeXmlAttr(serverName)}"${attrs}>\n${content}\n</${CHANNEL_TAG}>` |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Effective allowlist for the current session. Team/enterprise orgs can set |
no test coverage detected