Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in p:unescape-markup with tagsoup #75

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

NPE in p:unescape-markup with tagsoup #75

ndw opened this issue Feb 14, 2013 · 1 comment

Comments

@ndw
Copy link
Owner

@ndw 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
Copy link
Owner Author

@ndw 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.