Skip to content

Commit 4e006bd

Browse files
authored
fix: forbid access to object prototype props in mml parser (#43)
1 parent 68f33df commit 4e006bd

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/parser/parser.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,9 @@ test('invalid MML', () => {
9898
const mml = '<input name="test" value=1 />';
9999
expect(() => SourceToXML(mml)).toThrowError(/Attribute value expected/);
100100
});
101+
102+
test('forbid access to object prototype props in mml', () => {
103+
const mml = '<constructor />';
104+
const nodes = SourceToXML(mml);
105+
expect(() => XMLtoMMLTree(nodes)).toThrowError(/Converter not found for tag constructor.+/);
106+
});

src/parser/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class Tree {
3636

3737
(parent.children || []).forEach((child, i) => {
3838
const converter = this.converters[child.name];
39-
if (!converter) {
39+
if (!converter || !Object.hasOwnProperty.call(this.converters, child.name)) {
4040
throw Error(
4141
`Converter not found for tag ${child.name}, Available converters are ${Object.keys(this.converters)}`,
4242
);

0 commit comments

Comments
 (0)