[fpc-pascal] Test for valid ip address
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Jul 28 10:36:45 CEST 2016
On Thu, 28 Jul 2016 10:26:32 +0200
Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
> On 28/07/16 10:14, Koenraad Lelong wrote:
> > I need a way to test if an string containing an ipv4-address is really
> > an ipv4-address.
> > I tried
> > tmpAddress:=HostAddrToStr(StrToHostAddr(IPAddressStr));
> > writeln(tmpAddress);
> > if (tmpAddress='0.0.0.0') then
> > begin
> > writeln('Error in IP-address');
> > IPAddressStr:=tmpAddress;
> > end;
> > When I enter 192.168.185.297 (i.e. not a valid ipv4 address) in
> > IPAddressStr I get
> > 192.168.185.41
> > not the expected error-message.
>
> You can add a multiple of 256 to any octet of an IPv4 address in most
> programs. Try it in your browser, it will probably also work.
What browser supports that?
Mattias
More information about the fpc-pascal
mailing list