1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
From fbf66f20daf5df2bc70509870ba98e61de7e56e1 Mon Sep 17 00:00:00 2001
From: Steffen Ullrich <Steffen_Ullrich@genua.de>
Date: Sat, 22 Nov 2014 21:39:18 +0100
Subject: [PATCH] make PublicSuffix::_default_data thread safe by storing the
default data inside a function inside within __DATA__
---
lib/IO/Socket/SSL/PublicSuffix.pm | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lib/IO/Socket/SSL/PublicSuffix.pm b/lib/IO/Socket/SSL/PublicSuffix.pm
index a84aacd..8d3fa9b 100644
--- a/lib/IO/Socket/SSL/PublicSuffix.pm
+++ b/lib/IO/Socket/SSL/PublicSuffix.pm
@@ -292,7 +292,7 @@ sub public_suffix {
my $data;
sub _default_data {
if ( ! defined $data ) {
- $data = do { local $/; <DATA> };
+ $data = _builtin_data();
$data =~s{^// ===END ICANN DOMAINS.*}{}ms
or die "cannot find END ICANN DOMAINS";
}
@@ -309,8 +309,15 @@ sub update_self_from_url {
local $/ = "\n";
while (<$fh>) {
$code .= $_;
- $code =~m{\A__DATA__\r?\n\Z} and last;
+ m{<<'END_BUILTIN_DATA'} and last;
}
+ my $tail;
+ while (<$fh>) {
+ m{\AEND_BUILTIN_DATA\r?\n} or next;
+ $tail = $_;
+ last;
+ }
+ $tail .= do { local $/; <$fh> };
close($fh);
require LWP::UserAgent;
@@ -335,11 +342,10 @@ sub update_self_from_url {
}
open( $fh,'>:utf8',$dst ) or die "open $dst: $!";
- print $fh $code;
+ print $fh $code.$tail;
}
-1;
-__DATA__
+sub _builtin_data { return <<'END_BUILTIN_DATA' }
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -9154,3 +9160,6 @@ za.net
za.org
// ===END PRIVATE DOMAINS===
+
+END_BUILTIN_DATA
+1;
--
2.1.4
|