From e0b7cf5eb5e6828d07094fa44be67e2d7d63e722 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Jul 2016 22:28:26 +0000 Subject: localize $/ when using chomp 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(+) (limited to 'lib') diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 27f36a7e..bb0811a5 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 23b77213..4fbbb522 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 5b055bca..0c61dd8a 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 10101887..3808196c 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; -- cgit v1.2.3-24-ge0c7