Skip to content

HTML comments opened or closed with 3 dashes aren't tokenized correctly #512

@hrb-hub

Description

@hrb-hub
  • Comments closed with more than 2 dashes have their closing > escaped and replaced by &gt; resulting in actual markup being commented out. Note that for some dash counts, comments are handled okay like <!--comment-----> is okay.
  • Comments opened with 3 dashes have their first character clipped. <!---comment--> becomes <!---omment-->

To reproduce

import linkifyHtml from 'linkify-html';

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

	console.log({html, result})
}

main()

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions