[Gllug] Re: Bash Data validation libraries

Nix nix at esperi.org.uk
Tue Feb 14 23:27:43 UTC 2006


On Tue, 14 Feb 2006, Tethys whispered secretively:
> That's a *very* naive check (it's also a bashism, and won't work in other
> shells). BTW, your regexp could be simplified to:
> 
> 	^[1-9][0-9]{,2}(\.[1-9][0-9]{,2}){3}$
> 
> but it's still wrong because it allows 555.666.777.888 as an IP address.
> More worryingly, it also doesn't accept 192.168.0.1 as being a valid IP.
> You *could* do it with just regular expressions, albeit somewhat complex
> ones

We tried in SpamAssassin and the regexp got so unreadable that we ended
up turning it into an eval rule in Perl just for maintainability's sake.

Verifying valid IPs is a bit too hard to sanely do in a regexp (although
it is *possible*).

-- 
`... follow the bouncing internment camps.' --- Peter da Silva
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list