


























@@ -556,15 +556,23 @@ function readFirstString(
556556return undefined;
557557}
558558559-function readOptionalNumber(params: Record<string, unknown>, keys: string[]): number | undefined {
559+function isPositiveSafeInteger(value: number): boolean {
560+return Number.isSafeInteger(value) && value > 0;
561+}
562+563+function readOptionalPositiveInteger(
564+params: Record<string, unknown>,
565+keys: string[],
566+): number | undefined {
560567for (const key of keys) {
561568const value = params[key];
562-if (typeof value === "number" && Number.isFinite(value)) {
569+if (typeof value === "number" && isPositiveSafeInteger(value)) {
563570return value;
564571}
565572if (typeof value === "string" && value.trim()) {
566-const parsed = Number(value);
567-if (Number.isFinite(parsed)) {
573+const trimmed = value.trim();
574+const parsed = /^\d+$/.test(trimmed) ? Number(trimmed) : Number.NaN;
575+if (isPositiveSafeInteger(parsed)) {
568576return parsed;
569577}
570578}
@@ -939,7 +947,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
939947 chatId,
940948startTime: readFirstString(ctx.params, ["startTime", "start_time"]),
941949endTime: readFirstString(ctx.params, ["endTime", "end_time"]),
942-pageSize: readOptionalNumber(ctx.params, ["pageSize", "page_size"]),
950+pageSize: readOptionalPositiveInteger(ctx.params, ["pageSize", "page_size"]),
943951pageToken: readFirstString(ctx.params, ["pageToken", "page_token"]),
944952accountId: ctx.accountId ?? undefined,
945953});
@@ -972,7 +980,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
972980const members = await runtime.getChatMembers(
973981client,
974982chatId,
975-readOptionalNumber(ctx.params, ["pageSize", "page_size"]),
983+readOptionalPositiveInteger(ctx.params, ["pageSize", "page_size"]),
976984readFirstString(ctx.params, ["pageToken", "page_token"]),
977985resolveFeishuMemberIdType(ctx.params),
978986);
@@ -1009,7 +1017,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
10091017const members = await runtime.getChatMembers(
10101018client,
10111019chatId,
1012-readOptionalNumber(ctx.params, ["pageSize", "page_size"]),
1020+readOptionalPositiveInteger(ctx.params, ["pageSize", "page_size"]),
10131021readFirstString(ctx.params, ["pageToken", "page_token"]),
10141022resolveFeishuMemberIdType(ctx.params),
10151023);
@@ -1024,7 +1032,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
10241032if (ctx.action === "channel-list") {
10251033const runtime = await loadFeishuChannelRuntime();
10261034const query = readFirstString(ctx.params, ["query"]);
1027-const limit = readOptionalNumber(ctx.params, ["limit"]);
1035+const limit = readOptionalPositiveInteger(ctx.params, ["limit"]);
10281036const scope = readFirstString(ctx.params, ["scope", "kind"]) ?? "all";
10291037if (
10301038scope === "groups" ||
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。