From 398e859f0c002114b5efb7522734cab5647b5efe Mon Sep 17 00:00:00 2001 From: Pavan Kumar VH Date: Thu, 3 Sep 2026 10:40:33 +0530 Subject: [PATCH] Fix data URL validation in summarizeDataUrl The summarizeDataUrl function assumed the value started with 'data:' (5 chars) and sliced from index 5 to extract the media type. If the value didn't start with 'data:', this would return incorrect results. Added a check to ensure the header starts with 'data:' before slicing, returning 'unknown' as the media type if it doesn't. --- common/src/util/cache-debug.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/util/cache-debug.ts b/common/src/util/cache-debug.ts index 594ffb3faf..e9fdf4d60a 100644 --- a/common/src/util/cache-debug.ts +++ b/common/src/util/cache-debug.ts @@ -53,7 +53,7 @@ function summarizeDataUrl(value: string): SerializableValue { const payload = firstComma >= 0 ? value.slice(firstComma + 1) : '' return { type: 'data-url', - mediaType: header.slice(5).split(';')[0] || 'unknown', + mediaType: header.startsWith('data:') ? header.slice(5).split(';')[0] || 'unknown' : 'unknown', payloadLength: payload.length, preview: payload.slice(0, 32), }