Project

Profile

Help

Bug #4587

closed

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

Added by Martin Honnen almost 4 years ago. Updated about 3 years ago.

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

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
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.


Files

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
Actions #1

Updated by Michael Kay almost 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.

Actions #2

Updated by John Lumley almost 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.

Actions #3

Updated by John Lumley almost 4 years ago

  • Fix Committed on JS Branch Trunk added
Actions #4

Updated by Community Admin about 3 years ago

  • Applies to JS Branch 2 added
  • Applies to JS Branch deleted (2.0, Trunk)
Actions #5

Updated by Debbie Lockett about 3 years ago

  • Fix Committed on JS Branch 2 added
  • Fix Committed on JS Branch deleted (Trunk)
Actions #6

Updated by Debbie Lockett about 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