msva / lua-htmlparser

An HTML parser for lua.
231 stars 44 forks source link

variable 'htmlparser_opts' is not declared #64

Open PR0J3CT12 opened 11 months ago

PR0J3CT12 commented 11 months ago

Im getting error "variable 'htmlparser_opts' is not declared" after local htmlparser = require ("htmlparser"). How can i fix it?

msva commented 10 months ago

Can you add more information, please?

1) how did you installed package? 2) how do you use it (interactively, or in script) 3) can you post full stacktrace, please?

PR0J3CT12 commented 8 months ago

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.

  1. luarocks install htmlparser
  2. as i said before, im trying to use it in nse script
  3. 
    /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)
![Снимок](https://github.com/msva/lua-htmlparser/assets/45341405/c8d89f2d-54ef-4377-8311-83e0ba19367e)
msva commented 8 months ago

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".