From 511bb23999e57d835bd5934f2bf98cc331323acb Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:25:52 +0000 Subject: [PATCH] Strip leading byte-order mark in graph CSV parser Found while testing crates/engine/src/cmd/graph/data.rs:45-47 (parse_csv) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/graph/data.rs | 1 + crates/engine/src/cmd/graph/tests.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/crates/engine/src/cmd/graph/data.rs b/crates/engine/src/cmd/graph/data.rs index b49a0d6a8..3e2122349 100644 --- a/crates/engine/src/cmd/graph/data.rs +++ b/crates/engine/src/cmd/graph/data.rs @@ -43,6 +43,7 @@ fn cell(c: &str) -> Cell { } pub(super) fn parse_csv(csv: &str) -> (Vec, Vec, Vec>>) { + let csv = csv.strip_prefix('\u{feff}').unwrap_or(csv); // Records end at line breaks outside quotes; a record is tab-separated if it has a tab outside quotes. let rows: Vec> = split_unquoted(csv, '\n') .into_iter() diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 7acfc2c81..650a4275a 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -4205,3 +4205,8 @@ fn character_formats_are_kept_and_bigger_labels_space_out() { } } } + +#[test] +fn csv_leading_byte_order_mark_is_ignored() { + assert_eq!(super::parse_csv("\u{feff}1,2\n3,4"), super::parse_csv("1,2\n3,4")); +}