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


On Fri, May 29, 2009 at 13:53, Matt Kettler <[email protected]> wrote:

> Eric Rodriguez wrote:
> > Hi,
> >
> > I'm having trouble with the check invalid_ip subroutine in the
> > RelayEval.pm.
> > See
> >
> http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm?view=log&r1=451385&pathrev=451385
> > <
> http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayEval.pm?view=log&r1=451385&pathrev=451385
> >
> >
> > After a couple test, it seems that 193.X.X.X and 194.X.X.X ip's are
> > not "valid" with respect to the regexp.
> > Is this a bug? or am I wrong about the test?
> >
> > I used http://www.fileformat.info/tool/regex.htm with
> > RegExp:
> >
> (?:[01257]|(?!127.0.0.)127|22[3-9]|2[3-9]\d|[12]\d{3,}|[3-9]\d\d+)\.\d+\.\d+\.\d+
> > Tests:
> > 127.0.0.1
> > 192.168.1.1
> > 87.248.121.75
> > 193.1.1.1
> > 194.1.1.1
> >
> >
> > Could someone explain me which ip are "valid" according to this test ?
> > Thanks
> >
> > Eric Rodriguez
> Using the above tool I get results telling me that 193.1.1.1 and
> 194.1.1.1 do NOT match, and therefore are valid IPs.
>
> Test    Target String   matches()       replaceFirst()  replaceAll()
> lookingAt()     find()  group(0)
> 1       193.1.1.1       *No*    193.1.1.1       193.1.1.1       No      No
> 2       194.1.1.1       *No*    194.1.1.1       194.1.1.1       No      No
>
>
>
> In fact, NONE of your test strings match the regex. But 127.1.1.1,
> correctly, does.
>
>
>

Reply via email to