xline: accept the durationless KLINE/GLINE form (mask :reason) instead of eating the reason

This commit is contained in:
Jean Chevronnet 2026-08-16 18:21:32 +00:00
parent 5046083608
commit dadbff91d8

View file

@ -679,11 +679,18 @@ fn do_xline(s: &mut Server, uid: Uid, params: &[String], kind: XKind) -> CmdResu
); );
return CmdResult::Ok; return CmdResult::Ok;
} }
let dur = parse_duration(&params[1]).unwrap_or(0); // <mask> <duration> :<reason>; tolerate the durationless form by taking an
let reason = params // unparseable second token as the reason (permanent ban).
.get(2) let (dur, reason) = match parse_duration(&params[1]) {
.cloned() Some(d) => (
.unwrap_or_else(|| "No reason given".to_string()); d,
params
.get(2)
.cloned()
.unwrap_or_else(|| "No reason given".to_string()),
),
None => (0, params[1].clone()),
};
s.add_xline(kind, &mask, dur, &nick, &reason); s.add_xline(kind, &mask, dur, &nick, &reason);
s.propagate_addline(kind.tag(), &mask, &nick, dur, &reason); s.propagate_addline(kind.tag(), &mask, &nick, dur, &reason);
CmdResult::Ok CmdResult::Ok