From aca98ffe7952410e7ffe04f02df0d132373bb7e6 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:04:26 +0100 Subject: [PATCH] Reject non-hex characters in EPS uni/u glyph names Found while testing crates/eps/src/import/text.rs:501-502 (glyph_char) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/eps/src/import/text.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/eps/src/import/text.rs b/crates/eps/src/import/text.rs index 248f011bc..7b0df91f9 100644 --- a/crates/eps/src/import/text.rs +++ b/crates/eps/src/import/text.rs @@ -499,6 +499,7 @@ fn glyph_char(name: &str) -> char { return c; } if let Some(hex) = name.strip_prefix("uni").or_else(|| name.strip_prefix('u')) + && hex.chars().all(|c| c.is_ascii_hexdigit()) && let Some(c) = u32::from_str_radix(hex, 16).ok().and_then(char::from_u32) { return c; @@ -508,3 +509,16 @@ fn glyph_char(name: &str) -> char { _ => '\u{2022}', } } + +#[cfg(test)] +mod tests { + use super::glyph_char; + + #[test] + fn glyph_char_rejects_plus_in_hex() { + assert_eq!(glyph_char("uni20AC"), '€'); + assert_eq!(glyph_char("u1F600"), '\u{1F600}'); + assert_eq!(glyph_char("uni+041"), '\u{2022}'); + assert_eq!(glyph_char("u+41"), '\u{2022}'); + } +}