Project

Profile

Help

Bug #5938

closed

Trying to compile XSLT from file after setting set_configuration_property('http://saxon.sf.net/feature/allowedProtocols', 'http,https') gives java.lang.NullPointerException

Added by Martin Honnen 11 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Category:
Saxon-C Internals
Start date:
2023-03-24
Due date:
% Done:

100%

Estimated time:
Found in version:
12.1
Fixed in version:
12.2
Platforms:

Description

I am used to set the processor to only allow http and https as the allowed protocols if I tend to deploy Saxon with Java or .NET or Python to a server, the intent (which worked fine for me so far) is to disallow user code in XSLT/XPath/XQuery to access the file system with e.g. the doc, collection, unparsed-text, json-doc functions.

However, with SaxonC HE 12.1, that approach now gives me a NullPointerException when simply trying to compile some XSLT (from file):

from saxonche import *

with PySaxonProcessor(license=False) as proc:
    print(proc.version)

    proc.set_configuration_property('http://saxon.sf.net/feature/allowedProtocols', 'http,https')

    xslt30_processor = proc.new_xslt30_processor()

    xslt30_executable = xslt30_processor.compile_stylesheet(stylesheet_file='pipeline-for-svrl.xsl.SaxonEE12CompiledForHE.sef')

Output:

SaxonC-HE 12.1 from Saxonica
Traceback (most recent call last):
  File "C:\Users\marti\PycharmProjects\SaxonHEC12ProtocolRestrictionTest1\XSLTCompilationTest1.py", line 10, in <module>
    xslt30_executable = xslt30_processor.compile_stylesheet(stylesheet_file='pipeline-for-svrl.xsl.SaxonEE12CompiledForHE.sef')
  File "python_saxon\saxonc.pyx", line 1150, in saxonche.PyXslt30Processor.compile_stylesheet
RuntimeError: NullPointer exception found: java.lang.NullPointerException
	at net.sf.saxon.lib.ProtocolRestrictor.lambda$new$2(ProtocolRestrictor.java:55)
	at net.sf.saxon.lib.ProtocolRestrictor.lambda$new$3(ProtocolRestrictor.java:60)
	at net.sf.saxon.lib.ProtocolRestrictor.test(ProtocolRestrictor.java:70)
	at net.sf.saxon.lib.DirectResourceResolver.resolve(DirectResourceResolver.java:58)
	at net.sf.saxon.lib.ResourceRequest.resolve(ResourceRequest.java:130)
	at net.sf.saxon.option.cpp.SaxonCAPI.resolveFileToSource(SaxonCAPI.java:1186)
	at net.sf.saxon.option.cpp.Xslt30Processor.compileFromFile(Xslt30Processor.java:318)
. Line number: -1

I guess the NullPointerException is a bug in any case, I don't know whether subjecting the XSLT compilation to protocol restrictions is intended, I don't think this happened in 12.0.

For it's worth, I tried some similar Java code with Saxon HE 12.1

        Processor processor = new Processor(false);

        processor.setConfigurationProperty(Feature.ALLOWED_PROTOCOLS, "http,https");

        XsltCompiler xsltCompiler = processor.newXsltCompiler();

        XsltExecutable xsltExecutable = xsltCompiler.compile(new File("pipeline-for-svrl.xsl.SaxonEE12CompiledForHE.sef"));

and there I don't get any error or protocol exceptions.


Files

saxon-compile-xslt-with-prot-restr1.py (369 Bytes) saxon-compile-xslt-with-prot-restr1.py Martin Honnen, 2023-03-24 11:10
identity1.xsl (263 Bytes) identity1.xsl Martin Honnen, 2023-03-24 11:10

Please register to edit this issue

Also available in: Atom PDF