taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.11k stars 107 forks source link

parser.valid accepts malformed input #227

Open BadIdeaException opened 1 year ago

BadIdeaException commented 1 year ago

It seems that parser.valid accepts even the most ludicrously malformed input strings as valid HTML:

const { valid } = require('node-html-parser');

var valid = require("node-html-parser").valid;

valid('<p abc</p'); // false
valid('<div<p abc</p></span>'); // false
valid('<div><p abc</p></div>'); // true
valid('<div<p abc</a></div>'); // true
valid('@#><p'); // true
valid('<<>'); // true

Also see here on RunKit

As far as I can see, none of the above should be true.