Skip to content

fix: reject invalid characters in HTML tag names - #4083

Merged
UziTech merged 1 commit into
markedjs:masterfrom
spokodev:fix/html-tag-name-chars
Sep 4, 2026
Merged

fix: reject invalid characters in HTML tag names#4083
UziTech merged 1 commit into
markedjs:masterfrom
spokodev:fix/html-tag-name-chars

Conversation

@spokodev

@spokodev spokodev commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Per CommonMark (Raw HTML, and HTML blocks type 7) and GFM, an HTML tag name is [A-Za-z][A-Za-z0-9-]*. The block and inline tag regexes used [\w-] (and [\w:-] for the inline closing tag), so _ — and : on closing tags — were accepted. As a result sequences like <bar_baz>, <em_>…</em_> and </a:b> were emitted as raw HTML instead of being escaped as text.

This also removes an inconsistency where the inline opening-tag rule rejected : but the closing-tag rule accepted it.

Example:

foo <bar_baz> qux

before: <p>foo <bar_baz> qux</p> — after: <p>foo &lt;bar_baz&gt; qux</p> (matching commonmark.js).

Attribute names still accept _/: — only tag names are affected. Added a test/specs/new case covering inline open/close and block tags with _/:. Full spec and unit suites pass.

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

@spokodev is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
Image marked-website Ready Ready Preview Sep 3, 2026 2:29pm UTC

Request Review

@UziTech UziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 💯

@UziTech
UziTech merged commit 300bb1d into markedjs:master Sep 4, 2026
8 checks passed
github-actions Bot pushed a commit that referenced this pull request Sep 7, 2026
## [18.0.12](v18.0.11...v18.0.12) (2026-09-07)

### Bug Fixes

* allow a tab before the closing sequence of an ATX heading ([#4084](#4084)) ([4417582](4417582))
* allow one more level of nested brackets in a link label ([#4064](#4064)) ([37b28d8](37b28d8))
* do not add a newline to an empty code block ([#4073](#4073)) ([23b1706](23b1706))
* escape character references in autolink destinations ([#4053](#4053)) ([8f432f0](8f432f0))
* reject GFM email autolink when the domain ends in _ or - ([#4063](#4063)) ([df57534](df57534))
* reject invalid characters in HTML tag names ([#4083](#4083)) ([300bb1d](300bb1d))
* remove up to the fence indentation from each content line ([#4074](#4074)) ([0244f08](0244f08))
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

Successfully merging this pull request may close these issues.

3 participants