]> Sergey Matveev's repositories - public-inbox.git/commitdiff
localize $/ when using chomp
authorEric Wong <e@80x24.org>
Wed, 27 Jul 2016 22:28:26 +0000 (22:28 +0000)
committerEric Wong <e@80x24.org>
Wed, 27 Jul 2016 22:28:51 +0000 (22:28 +0000)
Callers may have localized $/ to something else, so make sure
we chomp the expected character(s) when calling chomp.

lib/PublicInbox/Import.pm
lib/PublicInbox/Inbox.pm
lib/PublicInbox/NNTP.pm
lib/PublicInbox/SaPlugin/ListMirror.pm

index 27f36a7e486b84337e1e4e4586ab9ec5251e4c65..bb0811a5b55a8547a4da967742a57a19aa71849c 100644 (file)
@@ -38,6 +38,7 @@ sub gfi_start {
 
        # wait for other processes to be done
        flock($lockfh, LOCK_EX) or die "lock failed: $!\n";
+       local $/ = "\n";
        chomp($self->{tip} = $git->qx(qw(rev-parse --revs-only), $self->{ref}));
 
        my @cmd = ('git', "--git-dir=$git_dir", qw(fast-import
index 23b77213b7a9d1b3adf4b8598ddca22035dea4a3..4fbbb522f9c9d208dd54a240a3b68662f90163a5 100644 (file)
@@ -106,6 +106,7 @@ sub description {
        my $desc = $self->{description};
        return $desc if defined $desc;
        $desc = try_cat("$self->{mainrepo}/description");
+       local $/ = "\n";
        chomp $desc;
        $desc =~ s/\s+/ /smg;
        $desc = '($GIT_DIR/description missing)' if $desc eq '';
@@ -118,6 +119,7 @@ sub cloneurl {
        return $url if $url;
        $url = try_cat("$self->{mainrepo}/cloneurl");
        my @url = split(/\s+/s, $url);
+       local $/ = "\n";
        chomp @url;
        $self->{cloneurl} = \@url;
 }
index 5b055bca0c9c9ef859e85fc7da4cef162668da67..0c61dd8a0b4ad22ba8c3b05d67442c5ae6677e7d 100644 (file)
@@ -125,6 +125,7 @@ sub process_line ($$) {
        my $res = eval { $req->($self, @args) };
        my $err = $@;
        if ($err && !$self->{closed}) {
+               local $/ = "\n";
                chomp($l);
                err($self, 'error from: %s (%s)', $l, $err);
                $res = '503 program fault - command not performed';
index 10101887bc668f45a141b941b8f69e33431a30d0..3808196c8969226ae5e40a25bd6a3b88e49efaee 100644 (file)
@@ -37,6 +37,7 @@ sub check_list_mirror_received {
        foreach my $cfg (@{$pms->{conf}->{list_mirror_check}}) {
                my ($hdr, $hval, $host_re, $addr_re) = @$cfg;
                my $v = $pms->get($hdr) or next;
+               local $/ = "\n";
                chomp $v;
                next if $v ne $hval;
                return 1 if $recvd !~ $host_re;
@@ -53,6 +54,7 @@ sub check_list_mirror_bcc {
                my ($hdr, $hval, $host_re, $addr_re) = @$cfg;
                defined $addr_re or next;
                my $v = $pms->get($hdr) or next;
+               local $/ = "\n";
                chomp $v;
                next if $v ne $hval;
                return 1 if !$tocc || $tocc !~ $addr_re;