FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Keep '#' inside a quoted .cube TITLE when parsing
NetterSilver7cd5acfcf9a3
diff --git a/crates/color/src/lut.rs b/crates/color/src/lut.rsindex 67590eb12..a8aa19a68 100644--- a/crates/color/src/lut.rs+++ b/crates/color/src/lut.rs@@ -226,7 +226,14 @@ impl Lut {return Err(err("keyword after table data"));}match key {- "TITLE" => title = line[5..].trim().trim_matches('"').to_string(),+ "TITLE" => {+ // a '#' inside a quoted title is part of the title, not a comment+ let rest = raw.trim_start()[5..].trim_start();+ title = match rest.strip_prefix('"').and_then(|q| q.split_once('"')) {+ Some((t, _)) => t.to_string(),+ None => line[5..].trim().trim_matches('"').to_string(),+ };+ }"LUT_1D_SIZE" => {size1 = it.next().and_then(|v| v.parse().ok()).ok_or_else(|| err("bad LUT_1D_SIZE"))?;if !(2..=65536).contains(&size1) {@@ -555,6 +562,15 @@ mod tests {}}+ #[test]+ fn cube_title_with_hash_roundtrips() {+ let mut c = Lut3d::identity(2);+ c.title = "Look #2".into();+ assert_eq!(Lut3d::parse_cube(&c.to_cube()).unwrap().title, "Look #2");+ let text = c.to_cube().replace("TITLE \"Look #2\"", "TITLE \"Look\" # note");+ assert_eq!(Lut::parse_cube(&text).unwrap().title, "Look");+ }+#[test]fn cube_roundtrip_3d_1d_and_shaper() {let mut c = wild(17);