lua-htmlparser
lua-htmlparser copied to clipboard
variable 'htmlparser_opts' is not declared
Im getting error "variable 'htmlparser_opts' is not declared" after local htmlparser = require ("htmlparser"). How can i fix it?
Can you add more information, please?
- how did you installed package?
- how do you use it (interactively, or in script)
- can you post full stacktrace, please?
Mb im doing something wrong, but im trying to use library in nse(nmap scripting engine). Im not sure, that i can use libraries like in pure lua.
- luarocks install htmlparser
- as i said before, im trying to use it in nse script
/usr/local/share/lua/5.3/htmlparser.lua:14: variable 'htmlparser_opts' is not declared
stack traceback:
[C]: in function 'error'
/usr/bin/../share/nmap/nselib/strict.lua:80: in metamethod '__index'
/usr/local/share/lua/5.3/htmlparser.lua:14: in main chunk
[C]: in function 'require'
/usr/bin/../share/nmap/scripts/http-ssrf.nse:14: in function </usr/bin/../share/nmap/scripts/http-ssrf.nse:1>
UPD:
lib "gumbo" is working with nse, as i can see, idk why)
It seems, this engine redefines the metatables, and this causes a problem (originally the line it points to calls a function that checks if htmlparser_opts
is a table, and it being nil
is originally acceptable option (it just won't return anything).
Also, I just tested on clean lua5.3 and there is no such error. So it is definitelly the engine's who is guilty.
As a workaround I suggest you to just define htmlparser_opts
(global) variable as ampty table (or not empty, if you want to modify some settings) before require"htmlparser"
.