manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱
MIT License
287 stars 73 forks source link

double tag causes an error. #21

Closed hhrhhr closed 5 years ago

hhrhhr commented 5 years ago

file xml_bug.xml:

local xml2lua = require("xml2lua")
local handler = require("xmlhandler.tree")
local xml = [[
<tag1>
    <tag2/>
    <tag2/>
</tag1>
]]
local parser = xml2lua.parser(handler)
parser:parse(xml)

output:

: .\xmlhandler\tree.lua:118: bad argument #1 to 'insert' (table expected, got string)
stack traceback:
        [C]: in function 'table.insert'
        .\xmlhandler\tree.lua:118: in function 'xmlhandler.tree.starttag'
        .\XmlParser.lua:345: in upvalue 'parseNormalTag'
        .\XmlParser.lua:377: in upvalue 'parseTagType'
        .\XmlParser.lua:449: in function 'XmlParser.parse'
        xml_bug.lua:10: in main chunk
        [C]: in ?
hhrhhr commented 5 years ago

Very strange. Yesterday I tried different versions of Lua and sank this bug on all of them. And today, after rebooting the computer, everything works without errors.

If I don’t figure out how to repeat the problem, then tomorrow I’ll close the issue.

manoelcampos commented 5 years ago

Thanks. Anyway, which Lua version are you using?

hhrhhr commented 5 years ago

5.3.1 from ZeroBrane Studio and 5.3.5 compiled manually.

manoelcampos commented 5 years ago

Hey @hhrhhr, another user reported the same issue and I could reproduce it. I finally found out how to fix it. Check the commit in issue #23

hhrhhr commented 5 years ago

Thank you so much!