From acee6cccd802cf76085f8b52f7128f37e86a1b4f Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 21 Oct 2026 07:30:34 +0200 Subject: [PATCH] Keep fallback library name for blank GPL Name line Found while testing crates/color/src/palette_io.rs:373 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/color/src/palette_io.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/color/src/palette_io.rs b/crates/color/src/palette_io.rs index c8564e052..1572f72b1 100644 --- a/crates/color/src/palette_io.rs +++ b/crates/color/src/palette_io.rs @@ -371,7 +371,9 @@ fn read_gpl(text: &str, fallback: &str) -> SwatchLibrary { continue; } if let Some(n) = line.strip_prefix("Name:") { - lib.name = n.trim().to_string(); + if !n.trim().is_empty() { + lib.name = n.trim().to_string(); + } continue; } // Comments, headers (`Columns: 4`) and anything else that isn't a colour are skipped. @@ -648,6 +650,14 @@ mod tests { use crate::{Gradient, GradientPaint, GradientStop}; use proptest::prelude::*; + #[test] + fn gpl_blank_name_keeps_fallback() { + let blank = "GIMP Palette\nName: \nColumns: 0\n#\n 1 2 3\tx\n"; + assert_eq!(read(blank, "fallback").unwrap().name, "fallback"); + let named = "GIMP Palette\nName: Warm\n 1 2 3\tx\n"; + assert_eq!(read(named, "fallback").unwrap().name, "Warm"); + } + /// A color book's string: a `u32` count of UTF-16 code units, then the units. fn acb_str(out: &mut Vec, s: &str) { let units: Vec = s.encode_utf16().collect();