manoelcampos / xml2lua

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

"string" reserved word used as a parameter to string.sub #3

Closed michaeltalyansky closed 7 years ago

michaeltalyansky commented 7 years ago

In xml.lua:292:

tagstr = tagstr .. string.sub(string,endmatch,extend-1)

In my environment this dies, because 'string' is a string library:

luajit: ../xml.lua:292: bad argument #1 to 'sub' (string expected, got table)
stack traceback:
    [C]: in function 'sub'
    ../xml.lua:292: in function 'parse'
    example.lua:40: in main chunk
    [C]: at 0x00404e10

If I replace this line with:

tagstr = tagstr .. string.sub(str,endmatch,extend-1)

all seems to work fine. I think there are other places in the code that have a similar issue.

Is this a legitimate problem? Will be happy to fix if it is.

Thanks!

manoelcampos commented 7 years ago

Thanks for reporting. This is an actual issue. It should be as you mentioned, since str is the parameter for the obj.parse function, which is expected to be passed to string.sub().

I appreciate your help.

manoelcampos commented 7 years ago

Hi @ michaeltalyansky, I've fixed this issue and also completely refactored and re-organized the project. Now it's an actual Lua module which can be called using require("luaxml"). Check the new documentation, example and the message of the commit 2997c378ae9709bc406ac7d9eb5aacd64405aab9.

Realize the module was also renamed, as explained in f3134e11760b8b7ac05585a4b76e746994995858

I appreciate if you could give some feedback. Thanks.