From 5fb5f087d6a4aa6c3d5bdb30326598dff30c10d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 12 Oct 2021 00:36:08 +0200 Subject: [PATCH] hashtag bug fix --- CHANGELOG.md | 11 +++++++++-- src/command.rs | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 759d546..fa464a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,17 @@ # Changelog +## v0.4.2 +- Fix URL fragment detected as hashtag + ## v0.4.1 -- Add a translation system using the `locales` folder and `messages.json` -- Add more trace logging +- "en" translation fixes +- add `messages.json` - Config files are now parsed as JSON5 = comments are allowed +## v0.4.0 +- Add a translation system using the `locales` folder +- Add more trace logging + ## v0.3.0 - Changed config/storage format to directory-based, removed shared config mutex - Made more options configurable (timeouts, catch-up limits, etc) diff --git a/src/command.rs b/src/command.rs index 9bcb6f9..b0036df 100644 --- a/src/command.rs +++ b/src/command.rs @@ -135,13 +135,13 @@ static RE_PING: once_cell::sync::Lazy = Lazy::new(|| command!(r"ping")); static RE_ANNOUNCE: once_cell::sync::Lazy = Lazy::new(|| Regex::new(r"(?:^|\s|>|\n)[\\/]announce\s+(.*)$").unwrap()); -static RE_A_HASHTAG: once_cell::sync::Lazy = Lazy::new(|| Regex::new(r"(?:^|\b|\s|>|\n)#(\w+)").unwrap()); +static RE_A_HASHTAG: once_cell::sync::Lazy = Lazy::new(|| Regex::new(r"(?:^|\s|>|\n)#(\w+)").unwrap()); pub static RE_NOBOT_TAG: once_cell::sync::Lazy = - Lazy::new(|| Regex::new(r"(?:^|\b|\s|>|\n)#nobot(?:\b|$)").unwrap()); + Lazy::new(|| Regex::new(r"(?:^|\s|>|\n)#nobot(?:\b|$)").unwrap()); pub static RE_HASHTAG_TRIGGERING_PLEROMA_BUG: once_cell::sync::Lazy = - Lazy::new(|| Regex::new(r"(?:^|\b|\s|>|\n)#\w+[^\s]*$").unwrap()); + Lazy::new(|| Regex::new(r"(?:^|\s|>|\n)#\w+[^\s]*$").unwrap()); pub fn parse_status_tags(content: &str) -> Vec { debug!("Raw content: {}", content); @@ -563,6 +563,8 @@ mod test { assert!(RE_A_HASHTAG.is_match("#городДляЛюдей")); assert!(RE_A_HASHTAG.is_match("foo #banana gfdfgd")); assert!(RE_A_HASHTAG.is_match("foo #городДляЛюдей aaa")); + assert!(!RE_A_HASHTAG.is_match("foo https://google.com/#banana gfdfgd")); + assert!(!RE_A_HASHTAG.is_match("foo https://google.com/?foo#banana gfdfgd")); for (i, c) in RE_A_HASHTAG.captures_iter("foo #banana #χαλβάς #ласточка").enumerate() { if i == 0 { @@ -590,7 +592,7 @@ mod test { assert!(!RE_NOBOT_TAG.is_match("banana #tag sdfsd")); assert!(!RE_NOBOT_TAG.is_match("banana #nobotanicals sdfsd")); assert!(RE_NOBOT_TAG.is_match("#nobot")); - assert!(RE_NOBOT_TAG.is_match("aaa#nobot")); + assert!(RE_NOBOT_TAG.is_match("aaa\n#nobot")); assert!(RE_NOBOT_TAG.is_match("aaa #nobot")); assert!(RE_NOBOT_TAG.is_match("#nobot xxx")); assert!(RE_NOBOT_TAG.is_match("#nobot\nxxx"));