Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Uncaught error when tag contains multiple invalid attributes #239

Copy link
Copy link

Description

@knolleary
Issue body actions

If an XML tag contains more than one invalid attribute, such as <one two three>, and parseString is used in async mode, it throws an uncaught error. If the tag contains only one invalid attribute , it doesn't throw the error.

This appears to have been broken by this commit: b4ccc87

Here is a testcase:

var xml2js = require('xml2js');

var parseString = xml2js.parseString;
parseString('<invalid xml string>', {async:true}, function (err, result) {
    if (err) {
        console.log("Caught",err);
    }
    else {
        console.log('ok');
    }
});

Expected result - the callback receives the error:

Caught [Error: Attribute without value
Line: 0
Column: 14
Char: s]

Actual result - the callback receives the error and an uncaught error is throw:

Caught [Error: Attribute without value
Line: 0
Column: 14
Char: s]

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Attribute without value
Line: 0
Column: 20
Char: >
    at error (/private/tmp/a/node-red/node_modules/xml2js/node_modules/sax/lib/sax.js:652:8)
    at strictFail (/private/tmp/a/node-red/node_modules/xml2js/node_modules/sax/lib/sax.js:675:22)
    at Object.write (/private/tmp/a/node-red/node_modules/xml2js/node_modules/sax/lib/sax.js:1224:11)
    at Parser.exports.Parser.Parser.processAsync (/private/tmp/a/node-red/node_modules/xml2js/lib/xml2js.js:256:41)
    at Object._onImmediate (/private/tmp/a/node-red/node_modules/xml2js/lib/xml2js.js:7:59)
    at processImmediate [as _immediateCallback] (timers.js:354:15)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.