linkifyjs icon indicating copy to clipboard operation
linkifyjs copied to clipboard

HTML comment of a single hyphen isn't tokenized correctly

Open hrb-hub opened this issue 1 month ago • 1 comments

  • Comments containing noting but a single - are not terminated properly, causing actual markup to be commented out. Note that a double hyphen -- has the same effect.

To reproduce

import linkifyHtml from 'linkify-html';

function main() {
	const html = `<div><!----->Markup</div>`
	const result = linkifyHtml(html, {defaultProtocol: "https"})

	console.log({html, result})
}

main()

See that the output of linkifyHtml("<div><!----->Markup</div>", {defaultProtocol: "https"}) is "<div><!-----&gt;Markup&lt;/div&gt;-->"

hrb-hub avatar Nov 25 '25 15:11 hrb-hub

We will try to find time to contribute a fix for this issue, but if someone gets to it before we do, that's also fine by us :)

hrb-hub avatar Nov 25 '25 15:11 hrb-hub