You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/12/18 23:32:23 UTC

[trafficcontrol] branch master updated: Fix improper file slurping in Perl (#3143)

This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new bbf8beb  Fix improper file slurping in Perl (#3143)
bbf8beb is described below

commit bbf8beb08bcd3c53cd0134cba7284e3a85bac468
Author: Rawlin Peters <Ra...@gmail.com>
AuthorDate: Tue Dec 18 16:32:19 2018 -0700

    Fix improper file slurping in Perl (#3143)
    
    The proper way to enable slurp mode is by doing `local $/;`. When you do
    `undef $/` it is undefining the global `$/` input record separator which
    is bad and can cause a multitude of problems. Using the `local` version
    only nullifies the input record separator locally in order to enable
    slurp mode in that particular function rather than changing it globally.
---
 traffic_ops/app/lib/API/Iso.pm                                       | 2 +-
 traffic_ops/app/lib/Extensions/TrafficStats/Helper/InfluxResponse.pm | 2 +-
 traffic_ops/app/lib/UI/GenDbDump.pm                                  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/traffic_ops/app/lib/API/Iso.pm b/traffic_ops/app/lib/API/Iso.pm
index 4fe98d8..97d8f10 100644
--- a/traffic_ops/app/lib/API/Iso.pm
+++ b/traffic_ops/app/lib/API/Iso.pm
@@ -270,7 +270,7 @@ sub generate_iso {
 			}
 
 			# slurp it in..
-			undef $/;
+			local $/;
 			$data = <$fh>;
 
 			close $fh;
diff --git a/traffic_ops/app/lib/Extensions/TrafficStats/Helper/InfluxResponse.pm b/traffic_ops/app/lib/Extensions/TrafficStats/Helper/InfluxResponse.pm
index f4aaf5c..2b5a4da 100644
--- a/traffic_ops/app/lib/Extensions/TrafficStats/Helper/InfluxResponse.pm
+++ b/traffic_ops/app/lib/Extensions/TrafficStats/Helper/InfluxResponse.pm
@@ -36,7 +36,7 @@ sub parse_retention_period_in_seconds {
 	my $self             = shift;
 	my $retention_period = shift;
 
-	undef $/;
+	local $/;
 
 	my ( $hour, $minutes, $seconds ) = $retention_period =~ /(\d*)h(\d*)m(\d*)s/ms;
 
diff --git a/traffic_ops/app/lib/UI/GenDbDump.pm b/traffic_ops/app/lib/UI/GenDbDump.pm
index 6d2b14a..3e83241 100644
--- a/traffic_ops/app/lib/UI/GenDbDump.pm
+++ b/traffic_ops/app/lib/UI/GenDbDump.pm
@@ -40,7 +40,7 @@ sub dbdump {
 	}
 
 	# slurp it in..
-	undef $/;
+	local $/;
 	my $data = <$fh>;