Project

Profile

Help

Bug #4587

use of undefined system property like system-property('product') gives Internal error: bad input to string constructor

Added by Martin Honnen about 2 months ago. Updated about 2 months ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-06-14
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
2.0, Trunk
Fix Committed on JS Branch:
Trunk
Fixed in JS Release:
SEF Generated with:
Company:
-
Contact person:
-
Additional contact persons:
-

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.

sample1.xml (73 Bytes) sample1.xml Martin Honnen, 2020-06-14 14:58
undefined-system-property-test1.xsl (525 Bytes) undefined-system-property-test1.xsl Martin Honnen, 2020-06-14 14:58

History

#1 Updated by Michael Kay about 2 months 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.

#2 Updated by John Lumley about 2 months 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.

#3 Updated by John Lumley about 2 months ago

  • Fix Committed on JS Branch Trunk added

Please register to edit this issue

Also available in: Atom PDF Tracking page