fix(FN-7143): simplify base64 validation and improve error messages
This commit is contained in:
committed by
GitHub
parent
1bf8d83bc1
commit
8544b5b08b
@@ -325,7 +325,7 @@ export function TaskDocumentsTab({
|
||||
const dialog = lightboxDialogRef.current;
|
||||
const focusableElements = Array.from(dialog?.querySelectorAll<HTMLElement>(
|
||||
'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',
|
||||
) ?? []).filter((element) => !element.hasAttribute("disabled") && element.getAttribute("aria-hidden") !== "true");
|
||||
) ?? []).filter((element) => element.getAttribute("aria-hidden") !== "true");
|
||||
|
||||
if (!dialog || focusableElements.length === 0) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1514,12 +1514,9 @@ function decodeArtifactDataBase64(params: Static<typeof artifactRegisterParams>)
|
||||
}
|
||||
|
||||
const data = Buffer.from(normalized, "base64");
|
||||
if (data.length === 0 || data.toString("base64").replace(/=+$/, "") !== normalized.replace(/=+$/, "")) {
|
||||
throw new Error("dataBase64 must decode to non-empty artifact bytes.");
|
||||
}
|
||||
|
||||
if (!hasImageSignature(data, mimeType)) {
|
||||
throw new Error("dataBase64 must decode to valid image bytes matching mimeType.");
|
||||
throw new Error(`dataBase64 must decode to valid image bytes matching mimeType ${mimeType}.`);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user