mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-06 01:11:42 +00:00
21 lines
614 B
TypeScript
21 lines
614 B
TypeScript
// Feishu plugin module implements external keys behavior.
|
|
const CONTROL_CHARS_RE = /\p{Cc}/u;
|
|
const MAX_EXTERNAL_KEY_LENGTH = 512;
|
|
|
|
export function normalizeFeishuExternalKey(value: unknown): string | undefined {
|
|
if (typeof value !== "string") {
|
|
return undefined;
|
|
}
|
|
const normalized = value.trim();
|
|
if (!normalized || normalized.length > MAX_EXTERNAL_KEY_LENGTH) {
|
|
return undefined;
|
|
}
|
|
if (CONTROL_CHARS_RE.test(normalized)) {
|
|
return undefined;
|
|
}
|
|
if (normalized.includes("/") || normalized.includes("\\") || normalized.includes("..")) {
|
|
return undefined;
|
|
}
|
|
return normalized;
|
|
}
|