Strip IRC control characters

This commit is contained in:
Yash Karandikar 2022-01-15 15:13:35 -06:00
parent b52451ee9c
commit 9b87536c09
Signed by untrusted user: karx
GPG key ID: A794DA2529474BA5

View file

@ -281,6 +281,7 @@ async fn irc_loop(
lazy_static! {
static ref PING_NICK_1: Regex = Regex::new(r"^[\w+]+(:|,)").unwrap();
static ref PING_RE_2: Regex = Regex::new(r"@[^0-9\s]+").unwrap();
static ref CONTROL_CHAR_RE: Regex = Regex::new(r"\\x1f|\\x02|\\x12|\\x0f|\\x16|\\x03(?:\d{1,2}(?:,\d{1,2})?)?").unwrap();
}
client.identify()?;
@ -392,6 +393,8 @@ async fn irc_loop(
.to_string();
}
computed = CONTROL_CHAR_RE.replace_all(&computed, "").to_string();
w.username(nickname);
w.content(computed);
w