("")
+
+ useEffect(() => {
+ // Validate and sanitize the screenshot data
+ if (screenshot && typeof screenshot === "string") {
+ // Check if it's a valid data URL
+ if (screenshot.startsWith("data:image/")) {
+ // Extract the base64 part and validate it
+ const base64Match = screenshot.match(/^data:image\/[^;]+;base64,(.+)$/)
+ if (base64Match && base64Match[1]) {
+ try {
+ // Validate base64 by attempting to decode a small portion
+ // This will throw if the base64 is invalid
+ atob(base64Match[1].substring(0, 100))
+ // If successful, use the original screenshot
+ setValidatedSrc(screenshot)
+ setImageError(false)
+ } catch (_e) {
+ console.error("Invalid base64 in screenshot data")
+ setImageError(true)
+ }
+ } else {
+ setImageError(true)
+ }
+ } else {
+ setImageError(true)
+ }
+ } else {
+ setImageError(true)
+ }
+ }, [screenshot])
+
+ if (imageError || !validatedSrc) {
+ // Fallback UI when screenshot is invalid
+ return (
+
+ Screenshot unavailable
+
+ )
+ }
+
+ return (
+
setImageError(true)}
+ />
+ )
+})
+
export default BrowserSessionRow