From 25bb8ee3b4f7e2430b1fab645aace1825ce4e419 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 23 Apr 2025 13:37:09 -0500 Subject: [PATCH 1/2] test(token): Weird email case --- crates/typos/src/tokens.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/typos/src/tokens.rs b/crates/typos/src/tokens.rs index e715bf9c..adbeb2f3 100644 --- a/crates/typos/src/tokens.rs +++ b/crates/typos/src/tokens.rs @@ -1653,7 +1653,7 @@ mod test { fn tokenize_ignore_email() { let parser = TokenizerBuilder::new().build(); - let input = "Good example@example.com Bye"; + let input = "Good example@example.com if=@nam iff=@nam Bye"; let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect(); assert_data_eq!( actual.to_debug(), @@ -1664,10 +1664,15 @@ mod test { case: None, offset: 0, }, + Identifier { + token: "nam", + case: None, + offset: 38, + }, Identifier { token: "Bye", case: None, - offset: 25, + offset: 42, }, ] @@ -1683,10 +1688,15 @@ mod test { case: None, offset: 0, }, + Identifier { + token: "nam", + case: None, + offset: 38, + }, Identifier { token: "Bye", case: None, - offset: 25, + offset: 42, }, ] From e30fd36452e20fbdd9fa4b7235b0f23c99fb895e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 23 Apr 2025 13:42:12 -0500 Subject: [PATCH 2/2] fix(token): Improve email detection by prefering that over base64 Found in #1282 --- crates/typos/src/tokens.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/crates/typos/src/tokens.rs b/crates/typos/src/tokens.rs index adbeb2f3..db0bc578 100644 --- a/crates/typos/src/tokens.rs +++ b/crates/typos/src/tokens.rs @@ -188,15 +188,15 @@ mod parser { // - Update `is_ignore_char` to make sure `sep1` doesn't eat it all up // - Make sure you always consume it terminated(uuid_literal, peek(sep1)), - terminated(hash_literal, peek(sep1)), + terminated(email_literal, peek(sep1)), + terminated(url_literal, peek(sep1)), + terminated(jwt, peek(sep1)), terminated(base64_literal, peek(sep1)), // base64 should be quoted or something + terminated(hash_literal, peek(sep1)), terminated(ordinal_literal, peek(sep1)), terminated(hex_literal, peek(sep1)), terminated(dec_literal, peek(sep1)), // Allow digit-prefixed words - terminated(email_literal, peek(sep1)), - terminated(url_literal, peek(sep1)), terminated(css_color, peek(sep1)), - terminated(jwt, peek(sep1)), c_escape, printf, other, @@ -1664,11 +1664,6 @@ mod test { case: None, offset: 0, }, - Identifier { - token: "nam", - case: None, - offset: 38, - }, Identifier { token: "Bye", case: None, @@ -1688,11 +1683,6 @@ mod test { case: None, offset: 0, }, - Identifier { - token: "nam", - case: None, - offset: 38, - }, Identifier { token: "Bye", case: None,