channelban: leave the a: (account) extban mask verbatim — normalize_ban_mask was appending !*@* and breaking account matching
This commit is contained in:
parent
bcd958d2d3
commit
33a18b81cc
1 changed files with 12 additions and 4 deletions
|
|
@ -1455,10 +1455,10 @@ pub fn normalize_ban_mask(m: &str) -> String {
|
|||
let b = m.as_bytes();
|
||||
if b.len() >= 2 && b[1] == b':' && (b[0] as char).is_ascii_alphabetic() {
|
||||
// These extbans carry a name / spec / channel / server, not a host mask,
|
||||
// so they must not be host-normalised: g: (security group), y: (reputation
|
||||
// score), r: (realname), j: (channel), s: (server name), G: (country),
|
||||
// b: (banned-in-channel).
|
||||
if matches!(b[0], b'g' | b'y' | b'r' | b'j' | b's' | b'G' | b'b') {
|
||||
// so they must not be host-normalised: a: (account), g: (security group),
|
||||
// y: (reputation score), r: (realname), j: (channel), s: (server name),
|
||||
// G: (country), b: (banned-in-channel).
|
||||
if matches!(b[0], b'a' | b'g' | b'y' | b'r' | b'j' | b's' | b'G' | b'b') {
|
||||
return m.to_string();
|
||||
}
|
||||
return format!("{}:{}", &m[..1], normalize_mask(&m[2..]));
|
||||
|
|
@ -1470,6 +1470,14 @@ pub fn normalize_ban_mask(m: &str) -> String {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn account_extban_mask_is_left_verbatim() {
|
||||
// a: carries an account name, not a host mask — must not gain !*@*
|
||||
assert_eq!(normalize_ban_mask("a:someacct*"), "a:someacct*");
|
||||
// a bare nick is still host-normalised the usual way
|
||||
assert!(normalize_ban_mask("bob").contains('@'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn member_rank_and_prefix_char_take_the_highest() {
|
||||
let mut m = Member::default();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue