1 package Koha::XSLT::HTTPS;
3 # Copyright 2022 Rijksmuseum
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 Koha::XSLT::HTTPS - Helper module to resolve issues with https stylesheets
26 Koha::XSLT::HTTPS->load( $filename );
30 This module collects the contents of https XSLT styleheets where
31 libxml2/libxslt fail to do so. This should be considered as a
34 A similar problem comes up with xslt include files. The module could
35 be extended to resolve these issues too. What holds me back now, is
36 the fact that we need to parse the whole xslt code.
43 use Koha::Exceptions::XSLT;
49 Koha::XSLT::HTTPS->load( $filename );
54 my ( $class, $filename ) = @_;
56 Koha::Exceptions::XSLT::MissingFilename->throw if !$filename;
57 return { location => $filename } if $filename !~ /^https:\/\//;
59 my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } );
60 my $resp = $ua->get( $filename );
61 if( $resp->is_success ) {
62 my $contents = $resp->decoded_content;
63 # $contents = $self->_resolve_includes( $contents );
64 return { string => $contents };
66 Koha::Exceptions::XSLT::FetchFailed->throw;
69 sub _resolve_includes {
70 # We could parse the code for includes/imports, fetch them and change refs
71 my ( $self, $code ) = @_;
80 Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands