Skip to content

Commit

Permalink
Get rid of most uses of chomp, which is fragile.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcmyers committed Oct 11, 2021
1 parent fdc88b5 commit 8c39b9c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cgi-bin/civs_common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ sub GetPrivateHostID {
end_html();
exit 0;
}
$private_host_id=<HOSTID>;
chomp $private_host_id;
$private_host_id = <HOSTID>;
$private_host_id =~ s/(\s)+$//; # remove trailing whitespace
close(HOSTID);
}

Expand Down Expand Up @@ -275,7 +275,7 @@ sub SecureNonce {
open(NONCEFILE, "<$nonce_seed_file")
or die "Can't open nonce file for read: $!\n";
my $seed = <NONCEFILE>;
chomp $seed;
$seed =~ s/(\s)+$//;
close(NONCEFILE);
my $ret = substr($seed, 0, 16);

Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/election.pm
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ sub CheckElectionID {
# Log the string provided
sub ElectionLog {
my $log_msg = shift;
chomp($log_msg);
$log_msg =~ s/(\s)+$//;
my $now = strftime "%a %b %e %H:%M:%S %Y", localtime;
# print pre("trying to log to $election_log");
if (!open ELECTION_LOG, ">>$election_log") {
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/mail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sub init {

sub CheckAddr {
(my $addr) = @_;
chomp $addr;
$addr = &TrimAddr($addr);

return ($addr =~ m/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2,8})$/i);
}
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request_activation
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if (!defined($code)) {
$invites = <INVITES>;
my @lines = split /\n/, $invites;
for my $line (@lines) {
chomp $line;
$line =~ s/(\s)+$//;
(my $url, my $title) = split / /, $line, 2;
push @rows, [$url, $title];
}
Expand Down

0 comments on commit 8c39b9c

Please sign in to comment.