From 7ce131aaf8e471e77e16cafb028fc7d1fbc5be9c Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Wed, 30 Oct 2024 12:32:17 -0700 Subject: [PATCH] Trim whitespace from base64 encoded image data before decoding it (#19977) Closes #17956 Closes #16330 This fix is for both REPL (released) and notebook (unreleased) image Release Notes: - Fixed image support in REPL for certain versions of matplotlib that included preceding and/or trailing whitespace in the base64 image data --- crates/repl/src/outputs/image.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/repl/src/outputs/image.rs b/crates/repl/src/outputs/image.rs index 15881aa915..648f4aa82c 100644 --- a/crates/repl/src/outputs/image.rs +++ b/crates/repl/src/outputs/image.rs @@ -16,7 +16,7 @@ pub struct ImageView { impl ImageView { pub fn from(base64_encoded_data: &str) -> Result { - let bytes = BASE64_STANDARD.decode(base64_encoded_data)?; + let bytes = BASE64_STANDARD.decode(base64_encoded_data.trim())?; let format = image::guess_format(&bytes)?; let mut data = image::load_from_memory_with_format(&bytes, format)?.into_rgba8();