https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12758

--- Comment #18 from Marcel de Rooy <[email protected]> ---
My plan was somehting like this (unfinished on itself):
Still had to set the flag when I found a https ref.
And check for commented refs.
But this is just way too much imo.


sub _convert_https {
    my ( $self, $code, $key, $params ) = @_;
    my $level = $params->{level} // 0; # to limit recursion level

    if( $level > $self->max_recursion_level ) {
        die; #FIXME Exception
    }

    # Find refs and resolve recursively
    my ( $href, $tmp_name, $new_code, $flag, @replaces, $changed );
    while( $code =~
/<(?:xsl):(?:import|include)\s*href\s*=\s*['"]([^'"]+)['"]/gcs ) {
        $href = $1;
        if( $include_cache->{$href} ) {
            $new_code = $include_cache->{$href};
            $changed = 1;
        } else {
            $new_code = $self->_get_code( $href );
            ( $new_code, $flag )  = $self->_convert_https( $new_code, $href, {
level => $level + 1 } );
            $changed = 1 if $flag;
        }
        next unless $changed;
        $tmpname = MIME::Base64::encode_base64url( $href, q{} );
        if( !$self->{_tempdir} || !-e $self->{_tempdir}. '/'. $tmpname ) {
            $self->{_tempdir} //= File::Temp->newdir;
            write_file( $self->{_tempdir}. '/'. $tmpname, { binmode => ':utf8'
}, Encode::encode_utf8($new_code) );
        }
        push @replaces, { href => $href, file => $self->{_tempdir}. '/'.
$tmpname };
    }

    # Replace refs
    foreach my $h ( @replaces ) {
        $code =~
s/(?=<(?:xsl):(?:import|include)\s*href\s*=\s*)(['"])${h->{href}}['"]/$1${h->{file}}$1/;
    }

    # Finalize
    $include_cache->{$key} = $code if !$self->disable_caching && $changed &&
$key;
    return ( $code, $changed // 0 );
}

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to