From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4F70E1F855 for ; Wed, 27 Jul 2016 22:28:26 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] localize $/ when using chomp Date: Wed, 27 Jul 2016 22:28:26 +0000 Message-Id: <20160727222826.28699-1-e@80x24.org> List-Id: Callers may have localized $/ to something else, so make sure we chomp the expected character(s) when calling chomp. --- lib/PublicInbox/Import.pm | 1 + lib/PublicInbox/Inbox.pm | 2 ++ lib/PublicInbox/NNTP.pm | 1 + lib/PublicInbox/SaPlugin/ListMirror.pm | 2 ++ 4 files changed, 6 insertions(+) diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 27f36a7..bb0811a 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -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 diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 23b7721..4fbbb52 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -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; } diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 5b055bc..0c61dd8 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -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'; diff --git a/lib/PublicInbox/SaPlugin/ListMirror.pm b/lib/PublicInbox/SaPlugin/ListMirror.pm index 1010188..3808196 100644 --- a/lib/PublicInbox/SaPlugin/ListMirror.pm +++ b/lib/PublicInbox/SaPlugin/ListMirror.pm @@ -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; -- EW