lua-htmlparser icon indicating copy to clipboard operation
lua-htmlparser copied to clipboard

variable 'htmlparser_opts' is not declared

Open PR0J3CT12 opened this issue 8 months ago • 3 comments

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

PR0J3CT12 avatar Oct 25 '23 02:10 PR0J3CT12

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?

msva avatar Nov 03 '23 14:11 msva

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
/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) Снимок

PR0J3CT12 avatar Jan 22 '24 00:01 PR0J3CT12

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

msva avatar Jan 23 '24 01:01 msva