Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: TypeError #544

Closed
yevgenypats opened this issue Nov 11, 2019 · 2 comments
Closed

Bug: TypeError #544

yevgenypats opened this issue Nov 11, 2019 · 2 comments

Comments

@yevgenypats
Copy link

Hey there,

The following code produce TypeError: obj[charkey].match is not a function

xml2js = require('xml2js');
var parser = new xml2js.Parser();
parser.parseString(Buffer.from('3c4f3eff00002f3e3c5f2f3e3c2f4f3eff3e4f3ead3ce42f3e3ce4c9ff002fe4ad5f0109900aad3c4f3ead', 'hex')).toString()

TypeError: obj[charkey].match is not a function
    at SAXParser.onclosetag (/node_modules/xml2js/lib/parser.js:187:28)
    at emit (/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/node_modules/xml2js/lib/parser.js:325:31)
    at Parser.parseString (/node_modules/xml2js/lib/parser.js:5:59)

It was found by jsfuzz

Cheers,
Yevgeny

@Omega-Ariston
Copy link
Contributor

You may wanna double check the structure of your input XML. I tried several encoding format but none of them parsed to a correct XML.
8

@noBlubb
Copy link

noBlubb commented Feb 9, 2020

Input generated by the fuzzer (jsfuzz) is likely to not be valid xml. The library should be able to detect this properly instead of throwing a generic TypeError when accessing an invalid property / function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants