eXist-db / exist

eXist Native XML Database and Application Platform
https://exist-db.org
GNU Lesser General Public License v2.1
424 stars 179 forks source link

[BUG] Jing fails to validate when RNG refers external RNG over https. #3718

Open ambs opened 3 years ago

ambs commented 3 years ago

Describe the bug When trying to use validate:jing-report, with a local file, and local rng, it crashes if the rng file includes (xinclude) an external rng over https.

Expected behavior A clean report.

To Reproduce As far as I can tell, create a rng file with a https xinclude.

<grammar xmlns="http://relaxng.org/ns/structure/1.0" 
         xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" 
         xmlns:sch="http://purl.oclc.org/dsdl/schematron" 
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" ns="http://www.tei-c.org/ns/1.0">
    <include href="https://raw.githubusercontent.com/DARIAH-ERIC/lexicalresources/master/Schemas/TEILex0/out/TEILex0.rng">
        <start>
            <choice>
                <ref name="entry"/>
            </choice>
        </start>
    </include>
</grammar>

Validate a sample file as:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://dacl.zbr.pt/exist/rest/db/schemas/academia.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?><entry xmlns="http://www.tei-c.org/ns/1.0" xml:lang="pt">
            <form>
                <orth>anquinhas</orth>
            </form>
        </entry>

And validate with

xquery version "1.0";
declare namespace validate="http://exist-db.org/xquery/validation";

let $schema := xs:anyURI("/db/path/to/schema.rng")
let $file := "/db/path/to/file.xml"
return validate:jing-report(doc($file), $schema)

The error message is:

                    <message>Invalid URI:Expected scheme-specific part at index 6: https:</message>
                    <stacktrace>java.lang.IllegalArgumentException: Invalid URI: https: &gt; Expected scheme-specific part at index 6: https:
        at org.exist.xmldb.XmldbURI.create(XmldbURI.java:232)
        at org.exist.xmldb.XmldbURI.getPathSegments(XmldbURI.java:599)
        at org.exist.xmldb.XmldbURI.startsWith(XmldbURI.java:859)
        at org.exist.storage.NativeBroker.prepend(NativeBroker.java:536)
    [...]

After adding debug information, I could trace that XmldbURI function is being called with the string "https:" (just that).

Context (please always complete the following information): commit 73bf861888f0533744a9b752f13236984159e3b (develop) running on default docker image built with Java: openjdk version "1.8.0_282"

joewiz commented 3 years ago

@ambs Would you be able to provide an xqsuite demonstrating the problem? This really helps developers reproduce your report and incorporate tests into source to prevent regressions in the future. See the template here: https://github.com/eXist-db/exist/blob/develop/.github/ISSUE_TEMPLATE/bug_report.md. If you are unable to do this, please let us know, and perhaps someone in the community can help you out.

ambs commented 3 years ago

@joewiz will try to do that. I might take some time, as this is something I can do only in my free time. So, putting here the reply just for you to know I will work on that asap :)

ambs commented 3 years ago

Sorry, no free time yet for this. If someone else is able to help, help is welcome.