





















@@ -104,6 +104,16 @@ function displayGalleryPath(
104104return sanitizeGalleryText(value, params);
105105}
106106107+function sanitizeGalleryPreview(
108+value: string | null,
109+params: {
110+extraRoots?: readonly string[];
111+repoRoot: string;
112+},
113+) {
114+return value === null ? null : sanitizeGalleryText(value, params);
115+}
116+107117async function realpathIfExists(filePath: string): Promise<string | null> {
108118return fs.realpath(filePath).catch(() => null);
109119}
@@ -356,6 +366,7 @@ function artifactHref(evidencePath: string, artifactPath: string) {
356366async function buildProducerContextFile(params: {
357367allowedRoots: readonly string[];
358368artifactPath: string;
369+extraRoots: readonly string[];
359370filePath: string;
360371hrefEvidencePath: string;
361372previewKind: "json" | "text";
@@ -369,7 +380,14 @@ async function buildProducerContextFile(params: {
369380return {
370381href: artifactHref(params.hrefEvidencePath, params.artifactPath),
371382path: repoPath,
372-preview: await readPreview(realFile, params.previewKind).catch(() => null),
383+preview: await readPreview(realFile, params.previewKind)
384+.then((preview) =>
385+sanitizeGalleryPreview(preview, {
386+extraRoots: params.extraRoots,
387+repoRoot: params.repoRoot,
388+}),
389+)
390+.catch(() => null),
373391};
374392}
375393@@ -422,9 +440,19 @@ async function buildArtifactView(params: {
422440kind: params.artifact.kind,
423441 mediaKind,
424442path: displayPath,
425-preview: await readPreview(realFile, mediaKind).catch(
426-(error: unknown) => `Preview unavailable: ${formatErrorMessage(error)}`,
427-),
443+preview: await readPreview(realFile, mediaKind)
444+.then((preview) =>
445+sanitizeGalleryPreview(preview, {
446+extraRoots: params.extraRoots,
447+repoRoot: params.repoRoot,
448+}),
449+)
450+.catch((error: unknown) =>
451+sanitizeGalleryText(`Preview unavailable: ${formatErrorMessage(error)}`, {
452+extraRoots: params.extraRoots,
453+repoRoot: params.repoRoot,
454+}),
455+),
428456source: params.artifact.source,
429457};
430458}
@@ -603,6 +631,7 @@ async function findUxMatrixProducerRoot(params: {
603631604632async function buildProducerContext(params: {
605633evidencePath: string;
634+extraRoots: readonly string[];
606635hrefEvidencePath: string;
607636repoRoot: string;
608637summaryEntries: readonly QaEvidenceSummaryEntry[];
@@ -632,6 +661,7 @@ async function buildProducerContext(params: {
632661await buildProducerContextFile({
633662 allowedRoots,
634663artifactPath: toRepoRelativePath(repoRoot, producerPaths[file.key]),
664+extraRoots: params.extraRoots,
635665filePath: producerPaths[file.key],
636666hrefEvidencePath: params.hrefEvidencePath,
637667previewKind: file.previewKind,
@@ -784,6 +814,7 @@ export async function buildQaEvidenceGalleryModel(params: {
784814profile: summary.profile ?? null,
785815producerContext: await buildProducerContext({
786816 evidencePath,
817+extraRoots: [requestedRepoRoot],
787818 hrefEvidencePath,
788819 repoRoot,
789820summaryEntries: summary.entries,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。