diff --git a/src/main.rs b/src/main.rs index 9815f65..151353e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,6 +80,10 @@ fn lines_read_noempty(lines: &mut Lines) -> Result fn unfuck_cif_number(number: &str) -> Result { let mut buf = ArrayString::<2048>::new(); + // the split later will discard leading/trailing whitespace information, so we first check if it's there + if number.is_empty() || number.as_bytes()[0] == 32 || number.as_bytes()[number.len()-1] == 32 { + return Err(GrammarError(number.to_string())); + } let split = number.split_whitespace().collect::>(); let splitlen = split.len(); for (i, word) in split.iter().enumerate() {