]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: ensure we only handle ASCII whitespace
authorEric Wong <e@80x24.org>
Tue, 4 Jun 2019 08:20:40 +0000 (08:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 4 Jun 2019 10:06:18 +0000 (10:06 +0000)
RFC3977 does not have provisions for whitespace beyond ASCII
TAB, SP, CR and LF.  I doubt there's any NNTP clients broken
enough to be sending non-ASCII whitespace delimiters.

We're probably excessively liberal regarding TAB acceptance,
even; but it's probably too late to change at this point...

lib/PublicInbox/NNTP.pm

index 57300e89994032e92ac30825cbeaf53b72b1c080..be80560ffa4a965a02e597796790ad7082d08f4d 100644 (file)
@@ -121,7 +121,7 @@ sub args_ok ($$) {
 # returns 1 if we can continue, 0 if not due to buffered writes or disconnect
 sub process_line ($$) {
        my ($self, $l) = @_;
-       my ($req, @args) = split(/\s+/, $l);
+       my ($req, @args) = split(/[ \t]/, $l);
        return 1 unless defined($req); # skip blank line
        $req = lc($req);
        $req = eval {
@@ -959,7 +959,7 @@ sub event_read {
                $self->{rbuf} .= $$buf;
        }
        my $r = 1;
-       while ($r > 0 && $self->{rbuf} =~ s/\A\s*([^\r\n]*)\r?\n//) {
+       while ($r > 0 && $self->{rbuf} =~ s/\A[ \t\r\n]*([^\r\n]*)\r?\n//) {
                my $line = $1;
                return $self->close if $line =~ /[[:cntrl:]]/s;
                my $t0 = now();