Skip to content

Commit 335d38f

Browse files
committed
Check for constructor property
1 parent c907b5e commit 335d38f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/jsonata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ var jsonata = (function() {
12931293
}
12941294
for(var ii = 0; ii < matches.length; ii++) {
12951295
var match = matches[ii];
1296-
if (match && match.isPrototypeOf(result)) {
1296+
if (match && (match.isPrototypeOf(result) || match instanceof Object.constructor)) {
12971297
throw {
12981298
code: "D1010",
12991299
stack: (new Error()).stack,

test/implementation-tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,15 @@ describe("Tests that are specific to a Javascript runtime", () => {
974974
code: "D1010",
975975
});
976976
});
977+
it("should throw an error with constructor", async function() {
978+
const expr = jsonata('{} ~> | constructor | {"is_admin": true} |');
979+
expect(
980+
expr.evaluate()
981+
).to.eventually.be.rejected.to.deep.contain({
982+
position: 7,
983+
code: "D1010",
984+
});
985+
});
977986
});
978987
});
979988

0 commit comments

Comments
 (0)