
























@@ -6,6 +6,7 @@ import type { ApiContributor, Entry, MapConfig, User } from "./update-clawtribut
66const REPO = "openclaw/openclaw";
77const PER_LINE = 10;
88const AVATAR_PROBE_SIZE = 40;
9+const AVATAR_PROBE_MAX_BYTES = 256 * 1024;
910const AVATAR_SIZE = 48;
1011const CLAWTRIBUTORS_START = "<!-- clawtributors:start -->";
1112const CLAWTRIBUTORS_END = "<!-- clawtributors:end -->";
@@ -459,7 +460,7 @@ async function probeDefaultGitHubAvatar(login: string): Promise<boolean> {
459460if (!response.ok) {
460461return false;
461462}
462-const buffer = Buffer.from(await response.arrayBuffer());
463+const buffer = await readAvatarProbeBuffer(response);
463464const dimensions = readImageDimensions(buffer);
464465return Boolean(
465466dimensions && (dimensions.width > AVATAR_PROBE_SIZE || dimensions.height > AVATAR_PROBE_SIZE),
@@ -469,6 +470,43 @@ async function probeDefaultGitHubAvatar(login: string): Promise<boolean> {
469470}
470471}
471472473+async function readAvatarProbeBuffer(response: Response): Promise<Buffer> {
474+const contentLength = Number(response.headers.get("content-length") ?? 0);
475+if (Number.isFinite(contentLength) && contentLength > AVATAR_PROBE_MAX_BYTES) {
476+throw new Error(`avatar probe exceeded ${AVATAR_PROBE_MAX_BYTES} bytes`);
477+}
478+479+const reader = response.body?.getReader?.();
480+if (!reader) {
481+const buffer = Buffer.from(await response.arrayBuffer());
482+if (buffer.byteLength > AVATAR_PROBE_MAX_BYTES) {
483+throw new Error(`avatar probe exceeded ${AVATAR_PROBE_MAX_BYTES} bytes`);
484+}
485+return buffer;
486+}
487+488+const chunks: Buffer[] = [];
489+let total = 0;
490+for (;;) {
491+const { done, value } = await reader.read();
492+if (done) {
493+break;
494+}
495+if (!value?.byteLength) {
496+continue;
497+}
498+const chunk = Buffer.from(value);
499+const nextTotal = total + chunk.byteLength;
500+if (nextTotal > AVATAR_PROBE_MAX_BYTES) {
501+await reader.cancel().catch(() => undefined);
502+throw new Error(`avatar probe exceeded ${AVATAR_PROBE_MAX_BYTES} bytes`);
503+}
504+chunks.push(chunk);
505+total = nextTotal;
506+}
507+return Buffer.concat(chunks, total);
508+}
509+472510async function filterVisibleEntries(
473511entries: Entry[],
474512hiddenLogins: ReadonlySet<string>,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。