Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade htmlparser2 #1255

Open
alxndrsn opened this issue Oct 30, 2024 · 2 comments
Open

Upgrade htmlparser2 #1255

alxndrsn opened this issue Oct 30, 2024 · 2 comments

Comments

@alxndrsn
Copy link
Contributor

The current version behaves unhelpfully when Parser.write(undefined) is called:

code

h = e => (...args) => console.log(e, { args });
p = new (require('htmlparser2').Parser)({
  onend:h('onend'),
  onopentag:h('onopentag'),
  ontext:h('ontext'),
  onclosetag:h('onclosetag'),
});
p.write(undefined);
p.end();

with current dependency (3.9.2)

ontext { args: [ 'undefined' ] }
onend { args: [] }

with latest version (9.1.0)

Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at Tokenizer.shouldContinue (htmlparser2-undefined/node_modules/htmlparser2/lib/Tokenizer.js:608:41)
    at Tokenizer.parse (htmlparser2-undefined/node_modules/htmlparser2/lib/Tokenizer.js:616:21)
    at Tokenizer.write (htmlparser2-undefined/node_modules/htmlparser2/lib/Tokenizer.js:150:14)
    at Parser.write (htmlparser2-undefined/node_modules/htmlparser2/lib/Parser.js:460:28)
@matthew-white
Copy link
Member

I'm not opposed to updating htmlparser2. But I'm also having trouble thinking of how it could get passed undefined. Is there somewhere in Backend where that happens?

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Nov 3, 2024

I'm not opposed to updating htmlparser2. But I'm also having trouble thinking of how it could get passed undefined. Is there somewhere in Backend where that happens?

I doubt it happens deliberately. It happened to me while modifying SQL generation for export streaming (unjoiner()?) and took a while to understand why things were failing and what exactly I'd broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants