user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] localize $/ when using chomp
@ 2016-07-27 22:28 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-07-27 22:28 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-27 22:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27 22:28 [PATCH] localize $/ when using chomp Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).