Project

Profile

Help

Bug #4958

closed

saxon-js 2.1: Crash in Saxon.XPath.evaluate with certain predicates

Added by Michael Gunter almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2021-04-01
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 have isolated a crash condition that occurs using certain predicates. The problem can be seen in the code at https://github.com/Neuroboy23/saxon-test. This crash occurs in saxon-js 2.1. It does not occur in saxon-js 2.0.

Given this XML input:

<?xml version="1.0"?>
<objects>
    <object name="foo" />
    <object-ref name="foo" />
</objects>

And this code:

import Saxon from "saxon-js";
Saxon.XPath.evaluate(
    "//*[ends-with(local-name(), '-ref')]",
    document
);

The Saxon.XPath.evaluate call above crashes with the following exception:

C:\dev\saxon-test\node_modules\saxon-js\SaxonJS2N.js:4065
y){return F.substring(0,y.length)===y}function q(F,y){return F.substring(F.length-y.length)===y}function z(F,y){return y&&(y=y.next())?y.toString():F.collation||Xd.getInheritedProperty(F,"defaultCollation")}function P(F,y){y=F?p(F,"http://www.w3.org/2013/collation/UCA")&&36<F.length?aa(F,F.substring(37),y):p(F,"http://saxon.sf.net/collation")&&29<F.length?aa(F,F.substring(30),y):y.fixed.qa.jd[F]:pa();if(!y)throw new M("Unrecognized collation "+F,"FOCH0002");return y}function aa(F,y){if(""===y)y=pa();
                                                                                                                                                                                                                                                                                                                                                                                                         ^
TypeError: Cannot read property 'jd' of undefined
    at P (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4065:394)
    at Object.Ub (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4073:213)
    at ends-with (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4274:469)
    at C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4388:324
    at jc.K [as g] (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4387:511)
    at jc.next (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:3975:180)
    at lc.next (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:3976:69)
    at lc.ba.forEachItem (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:3971:574)
    at lc.ba.expand (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:3972:191)
    at Object.Yd (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:3992:174)
    at C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4381:382
    at Object.J [as evaluate] (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4357:15)
    at Object.evaluate (C:\dev\saxon-test\node_modules\←[4msaxon-js←[24m\SaxonJS2N.js:4605:248)
    at file:///C:/dev/saxon-test/index.js:17:33

Please register to edit this issue

Also available in: Atom PDF Tracking page