Bantracker duration parsing could be improved
Created by: ilbelkyr
Currently, if an op sets a ban duration in a format eir doesn't recognize (e.g.
~1y thinking it will be a year-long ban), this will silently assume the ban to expire in just
1 (which is assumed to be minutes by default). It'd probably be more desirable to complain to the commenting op.
The relevant code is in
sub calc_time: https://github.com/freenode/eir/blob/6a267fbb18ca7f1bb90542f7c69f3cdf29389b43/scripts/bantracker.pl#L718-L740
Allowing 'y' to indicate years would only be a partial solution as eir would still accept other invalid inputs. While it could be argued that those are the commenting op's problem, I feel it'd be nicer to tell them what they're doing wrong in that case.
Side note: The regex used uses a
\d character class. This probably ought to be
[0-9] to avoid matching Unicode digits that aren't handled as numbers by Perl, such as ٧ (U+0667, ARABIC-INDIC DIGIT SEVEN). Alternatively, the
/a modifier introduced in Perl 5.14 could be used.