Bug #4587
closeduse of undefined system property like system-property('product') gives Internal error: bad input to string constructor
100%
Description
I accidentally used an undefined system property name product
as the argument to system-property
and that gives an internal error in Saxon-JS 2 while Saxon HE Java seems to simply output an empty string.
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="/" name="xsl:initial-template">
<xsl:next-match/>
<xsl:comment>Run with {system-property('xsl:product')} {system-property('xsl:product-version')}</xsl:comment>
</xsl:template>
</xsl:stylesheet>
Any XML input serves:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<foo>bar</foo>
</root>
Run with xslt3 -xsl:sheet.xsl -s:sample.xml
and gives output
<?xml version="1.0" encoding="UTF-8"?><root>
<foo>bar</foo>
</root>Internal error: bad input to string constructor #undefined
Error
at Object.a [as internalError] (C:\Users\foo\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:26:474)
with a lengthy stack trace.
Files
Updated by Michael Kay over 4 years ago
Confirmed that the code in CoreFn.js (line 2160) doesn't seem to be handling this case.
It seems that we haven't been routinely running the system-property() tests in the XSLT3 test suite, our exceptions file notes that "the tests are disproportionately slow, complex, and impossible to debug". We should restrict the exception to tests system-property-10X.
But I'm not convinced that this case is covered by the other tests anyway.
Updated by John Lumley over 4 years ago
- Status changed from New to Resolved
- Assignee set to John Lumley
- Applies to JS Branch Trunk added
system-property()
patched to return empty string ""
for an unknown property.
Updated by Community Admin almost 4 years ago
- Applies to JS Branch 2 added
- Applies to JS Branch deleted (
2.0, Trunk)
Updated by Debbie Lockett almost 4 years ago
- Fix Committed on JS Branch 2 added
- Fix Committed on JS Branch deleted (
Trunk)
Updated by Debbie Lockett over 3 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in JS Release set to Saxon-JS 2.1
Bug fix applied in the Saxon-JS 2.1 maintenance release.
Please register to edit this issue
Also available in: Atom PDF Tracking page