Eric Rodriguez wrote:
> Hi,
>
> I removed the negation ~ , the begin ^ and end $ charaters from the
> original source:
> sub check_for_illegal_ip {
> my ($self, $pms) = @_;
>
> foreach my $rcvd ( @{$pms->{relays_untrusted}} ) {
>
> # (note this might miss some hits if the Received.pm skips any invalid
> IPs)
> foreach my $check ( $rcvd->{ip}, $rcvd->{by} ) {
> return 1 if ($check =~ /^
>
> (?:[01257]|(?!127.0.0.)127|22[3-9]|2[3-9]\d|[12]\d{3,}|[3-9]\d\d+)\.\d+\.\d+\.\d+
>
> $/x);
> }
> }
> return 0;
> }
>
>
> Here are my results:
> Test Target String matches() replaceFirst() replaceAll()
> lookingAt() find() group(0)
> 1 127.0.0.1 No 12 12 No Yes 7.0.0.1
> 2 192.168.1.1 No 19 19 No Yes 2.168.1.1
> 3 87.248.121.75 No 8 8 No Yes 7.248.121.75
> 4 193.1.1.1 No 193.1.1.1 193.1.1.1 No No
> 5 194.1.1.1 No 194.1.1.1 194.1.1.1 No No
>
>
>
> If I understand correctly the first 3 tests are valid IP, but not the
> 193.1.1.1 and 194.1.1.1 ??
>
> Eric Rodriguez
No, none of the 5 has "yes" in the "matches" column so they're all valid
(ie: none of them matches the regex).
The other columns are irrelevant to the application here. Please ignore
them unless you fully understand them.