newsdev/archieml-js

Document crashes JS parser (but works in Ruby)

Closed this issue · 3 comments

jarib commented

Here's a document that crashes the JS parser but works fine in Ruby:

{part1}

text1: foo bar

bar baz

* foo
* bar
* baz

:end
{}
$ node -e 'console.log(require("archieml").load(require("fs").readFileSync("test.aml", "utf-8")))'
/vg/google-drive-sync/node_modules/archieml/archieml.js:95
    stackScope.array.push('');
                    ^

TypeError: Cannot read property 'push' of null
    at parseArrayElement (/vg/google-drive-sync/node_modules/archieml/archieml.js:95:21)
    at Object.load (/vg/google-drive-sync/node_modules/archieml/archieml.js:52:7)
    at [eval]:1:33
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:413:34)
    at node.js:612:27
    at nextTickCallbackWith0Args (node.js:453:9)
    at process._tickCallback (node.js:382:13)
$ ruby -r archieml -e 'p Archieml.load(File.read("test.aml"))'
{"part1"=>{"text1"=>"foo bar\n\nbar baz\n\n* foo\n* bar\n* baz"}}
$

It works fine in python too. I'm curious what happens if you rewind the js version to 96fbe6c, just before support was added for freeform arrays. That's when a number of problems started.

jarib commented

Thanks for the fix, @abstrctn! I see you bumped the version number, but looks like you forgot to npm publish?

Right you are! Apologies, v0.4.2 should be published now.