NPE in p:unescape-markup with tagsoup #75

Closed
ndw opened this Issue Feb 14, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@ndw
Owner

ndw commented Feb 14, 2013

Reported by George Bina:

The following pipeline causes an NPE:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
     xmlns:c="http://www.w3.org/ns/xproc-step"
    xmlns:cx="http://xmlcalabash.com/ns/extensions" version="1.0">
    <p:input port="source">
        <p:inline>
            <c:request method="get"
                 href="https://twitter.com/xmlcalabash/status/300609184943177729"
                 override-content-type="text/html"/>
        </p:inline>
    </p:input>
    <p:output port="result"/>
    <p:http-request/>
    <p:unescape-markup namespace="http://www.w3.org/1999/xhtml"
         content-type="text/html"/>
</p:declare-step>

This triggers an NPE.
We investigated this and the underlying stack trace is:

com.xmlcalabash.core.XProcException: java.lang.NullPointerException
at com.xmlcalabash.library.UnescapeMarkup.tagSoup(Unknown Source)
at com.xmlcalabash.library.UnescapeMarkup.run(Unknown Source)
at com.xmlcalabash.runtime.XAtomicStep.run(Unknown Source)
at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
at ro.sync.xml.transformer.xproc.calabash.XProcTransformerImpl.transform(XProcTransformerImpl.java:355)
at ro.sync.xml.transformer.xproc.XProcTransformer$2.run(XProcTransformer.java:491)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.(Unknown Source)
at com.xmlcalabash.util.XProcURIResolver.resolveEntity(Unknown Source)
at org.ccil.cowan.tagsoup.Parser.push(Parser.java:777)
at org.ccil.cowan.tagsoup.Parser.rectify(Parser.java:1061)
at org.ccil.cowan.tagsoup.Parser.stagc(Parser.java:1016)
at org.ccil.cowan.tagsoup.HTMLScanner.scan(HTMLScanner.java:565)
at org.ccil.cowan.tagsoup.Parser.parse(Parser.java:449)
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:405)
at net.sf.saxon.event.Sender.send(Sender.java:152)
at net.sf.saxon.Configuration.buildDocument(Configuration.java:3659)
at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:367)
... 8 more

The problem seems to be that the XProcURIResolver set on the tagsoup.Parser receives a null systemId in the
resolveEntity(String publicId, String systemId)
callback and the first thing in that class is
URI baseURI = new URI(systemId);
which triggers the NPE in the URI constructor.

@ndw

This comment has been minimized.

Show comment
Hide comment
@ndw

ndw Feb 14, 2013

Owner

Indeed, presented with , tagsoup calls resolveEntity(null, null).

Owner

ndw commented Feb 14, 2013

Indeed, presented with , tagsoup calls resolveEntity(null, null).

ndw added a commit that referenced this issue Feb 14, 2013

@ndw ndw closed this Feb 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment