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

NPE on validate() #25

Closed
issa-tseng opened this issue Nov 24, 2017 · 8 comments
Closed

NPE on validate() #25

issa-tseng opened this issue Nov 24, 2017 · 8 comments

Comments

@issa-tseng
Copy link

validate('<submission xmlns="http://opendatakit.org/submissions" xmlns:orx="http://openrosa.org/xforms"><data><data id="build_Untitled-Form_1424401835" instanceID="uuid:70ab6d82-110a-4ba6-86ac-071d698fd3a3" submissionDate="2015-02-20T16:07:51.145Z" isComplete="true" markedAsCompleteDate="2015-02-20T16:07:51.145Z"><orx:meta><orx:instanceID>uuid:74ab6d82-110a-4ba6-86ac-071d698fd3a3</orx:instanceID></orx:meta><name>Trevor</name><age>31</age><birthday>2014-07-01</birthday><location/><photo>1424448426991.jpg</photo><favorite_color>blue</favorite_color></data></data>');

On version 2.7.4, this fails for me on validator.js:76 with an NPE on the reference to index 0.

@amitguptagwl
Copy link
Member

let me check

@amitguptagwl amitguptagwl removed the bug label Nov 28, 2017
@amitguptagwl
Copy link
Member

What if I close submission tag in above sample XML and then validate?

@amitguptagwl
Copy link
Member

closing as no update. Please reopen if you fell there is any issue.

@issa-tseng
Copy link
Author

So perhaps I misunderstand what validate() is meant to do, then. In your sample code it seems to return a boolean indicating if the XML is valid. If it crashes on invalid XML does that mean I also have to try/catch it?

@amitguptagwl
Copy link
Member

It should return return false only. if it is throwing error there may be some case to cover.

@issa-tseng
Copy link
Author

Right, so that's exactly what's happening. I simplified the case:

> fxp.validate('<a><b/>');
TypeError: Cannot read property '0' of undefined
    at checkForMatchingTag (/Users/cxlt/Code/opendatakit/jubilant/node_modules/fast-xml-parser/bin/validator.js:76:51)
    at Object.exports.validate (/Users/cxlt/Code/opendatakit/jubilant/node_modules/fast-xml-parser/bin/validator.js:16:18)
    at repl:1:5
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)

@amitguptagwl
Copy link
Member

I got your point now. I have fixed it. Sorry for the confusion.

@issa-tseng
Copy link
Author

No problem; thanks!

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

2 participants