From fc856ce1befddecd3b0004790c3fc44084081eef Mon Sep 17 00:00:00 2001 From: evilsocket Date: Wed, 30 Oct 2024 17:23:36 +0100 Subject: [PATCH] fix: make sure the name starts with a letter or underscore or dot --- src/core/handlers/onnx/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/handlers/onnx/mod.rs b/src/core/handlers/onnx/mod.rs index 6e86f50..a0e5d1e 100644 --- a/src/core/handlers/onnx/mod.rs +++ b/src/core/handlers/onnx/mod.rs @@ -127,6 +127,14 @@ fn in_range(low: char, c: char, high: char) -> bool { fn str_to_node_name(s: &str) -> String { let mut result = String::new(); + + // make sure the name starts with a letter or underscore or dot + if let Some(first) = s.chars().next() { + if !is_letter_or_underscore_or_dot(first) { + result.push('_'); + } + } + for c in s.chars() { if is_constituent(c) { result.push(c);