From ad7558f571ec8bb649fc8c70a2d28ad814280959 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 1 May 2014 18:04:50 +0100 Subject: [PATCH] Bug 12172: Use LWP::UserAgent for remote XSLT fetch This patch re-enables proper handling of https hosted remote xslt style sheets with recent releases of LWP (libwww-perl-5.837 and prior do not need this patch). --- C4/XSLT.pm | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index d85b048..5b1ed47 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -33,7 +33,7 @@ use C4::Reserves; use Encode; use XML::LibXML; use XML::LibXSLT; -use LWP::Simple; +use LWP::UserAgent; use vars qw($VERSION @ISA @EXPORT); @@ -43,7 +43,6 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( &XSLTParse4Display - &GetURI ); } @@ -53,19 +52,6 @@ C4::XSLT - Functions for displaying XSLT-generated content =head1 FUNCTIONS -=head2 GetURI - -GetURI file and returns the xslt as a string - -=cut - -sub GetURI { - my ($uri) = @_; - my $string; - $string = get $uri ; - return $string; -} - =head2 transformMARCXML4XSLT Replaces codes with authorized values in a MARC::Record object @@ -229,8 +215,14 @@ sub XSLTParse4Display { my $xslt = XML::LibXSLT->new(); my $style_doc; if ( $xslfilename =~ /^https?:\/\// ) { - my $xsltstring = GetURI($xslfilename); - $style_doc = $parser->parse_string($xsltstring); + my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ); + my $response = $ua->get($xslfilename); + if ( $response->is_success ) { + my $xsltstring = $response->decoded_content; + $style_doc = $parser->parse_string($xsltstring); + } else { + warn "Cannot fetch remote XSLT file"; + } } else { use Cwd; $style_doc = $parser->parse_file($xslfilename); -- 1.7.10.4