2 ms·
Seeing if a date is close to the current date with regular expressions = not a good idea.
by jrockway 17y ago
Seeing if a date is close to the current date with regular expressions = not a good idea.
- patio11 17y agoIt is a matter of going to war with the software you have, not the software you wish you have. SpamAssassin allows you to do plug-n-play logic for tests, but for implementation reasons only accepts regular expressions. Those are Good Enough for most email filtering tasks, very flexible, and have fairly predictable security and resource consequences. This is the architecture that lets spam assassins subject an email to literally hundreds of tests (though in fairness I think they're probably less efficient than just naive Bayesian but don't trust me, my anti-spam researcher days are almost three years in the rear view mirror at the moment) and evolve quickly with the quickly changing, particularized nature of the spam threat at any given installation. Not to say that its optimal -- it is not -- but there is a reason it is done that way as opposed to having a fully executable plugin architecture which would have access to your date parsing library of choice.
- gnosis 17y agoIf you look at the bug it's not a problem caused by using regular expressions as such, but rather by the choice of date to be "grossly in the future" (ie. so far in to the future that it couldn't be a legitimate date at the time the software is running). The regex was chosen to match 2010 to 2099, which it did just fine. So problem wasn't in choosing to use regex's but in choosing 2010 as the date. I'm sure that date was "grossly in the future" at some point (probably when the regex was first written), but obviously we are living in the future now and need the date to be moved forward.