From d4730232509d8bb98e48ec761f98a88a250c47f2 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 29 Jun 2022 12:16:46 +0000 Subject: [PATCH] Bug 12758: Introduce Koha::XSLT::Loader Content-Type: text/plain; charset=utf-8 Work in progress. This is the idea for a 'solution' ;) --- Koha/XSLT/Loader.pm | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Koha/XSLT/Loader.pm diff --git a/Koha/XSLT/Loader.pm b/Koha/XSLT/Loader.pm new file mode 100644 index 0000000000..e7f16b24cb --- /dev/null +++ b/Koha/XSLT/Loader.pm @@ -0,0 +1,68 @@ +package Koha::XSLT::Loader; + +# Copyright 2022 Rijksmuseum +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +=head1 NAME + +Koha::XSLT::Loader - Helper module to resolve issues with https stylesheets + +=head1 SYNOPSIS + + Koha::XSLT::Loader->load( $filename, $string ); # returns { string => $xslt_code } + # where the $xslt_code will no longer contain https references + +=head1 DESCRIPTION + + TODO Add some nice text + +=cut + +use Modern::Perl; + +use base qw(Class::Accessor); + +=head1 METHODS + +=head2 load + +sub load { + my ( $class, $filename, $code ) = @_; + + # TODO If you got code, check for https refs. If so, get them and + # turn into local file references. Cache them? + # Always return a string here. + + # TODO If you got filename, get the code. And go back to step 1. + +# my $https_code = $self->_https_workaround( $filename, $code ); +# return $https_code || $_[1]? +# { 'string' => $https_code // $_[1] }: { 'location' => $_[0]//'' }; +} + + + +#sub _https_workaround { # Routine added for bug 12758 (part 1) +# my ( $self, $file, $code ) = @_; +# return if $file!~/^https/i; +# require LWP::UserAgent; +# my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ); +# my $resp = $ua->get( $file ); +# return $resp->decoded_content if $resp->is_success; #undef otherwise +#} + +1; -- 2.20.1