Skip to content

case insensitive for HTML attributes - #1096

Open
RobinDev wants to merge 2 commits into
thephpleague:2.7from
RobinDev:2.7
Open

case insensitive for HTML attributes#1096
RobinDev wants to merge 2 commits into
thephpleague:2.7from
RobinDev:2.7

Conversation

@RobinDev

Copy link
Copy Markdown

The HTML parser treated attribute names in a case-sensitive manner, which is not compliant with the HTML specifications.

This behavior caused incorrect escaping of tags containing attributes with uppercase letters, such as the viewBox attribute in SVG tags.

This change updates the PARTIAL_ATTRIBUTENAME regular expression to accept both uppercase and lowercase letters, ensuring that HTML attributes are correctly recognized regardless of their case.

@colinodell

Copy link
Copy Markdown
Member

Thanks for proposing this change! Would you mind sharing a specific example of the input you're using, and the incorrectly-escaped output? I'd like to include that as a regression test, and also use it to compare how other CommonMark-compliant parsers are handling this.

@colinodell colinodell added the not enough info We need more information to properly assist with this label Nov 26, 2025
@colinodell colinodell added the stale Issue may be closed soon due to inactivity label Jan 12, 2026
@stale stale Bot removed the stale Issue may be closed soon due to inactivity label Aug 12, 2026
@RobinDev

RobinDev commented Aug 12, 2026

Copy link
Copy Markdown
Author

Input:

Icon: <svg viewBox="0 0 4 4"><path d="M0 0h4v4z"/></svg> end.

Output (2.10.0, default CommonMarkConverter):

<p>Icon: &lt;svg viewBox=&quot;0 0 4 4&quot;&gt;<path d="M0 0h4v4z"/></svg> end.</p>

The uppercase letter in viewBox keeps the tag from matching inline raw HTML, so its < is escaped — <path> (lowercase attributes) passes through. The spec allows it: an attribute name is "an ASCII letter, _, or :, followed by zero or more ASCII letters, digits, …" (§6.6); commonmark.js uses attributename = "[a-zA-Z_:][a-zA-Z0-9:._-]*" (lib/common.js) — dingus.

Only inline is affected: the type-7 HTML block start regex is compiled with /i, so the same tag alone on its own line already works. This PR aligns inline with blocks.

Branch rebased on 2.7; the example is now a LocalDataTest fixture (raw_html_uppercase_attributes) plus two RegexHelperTest assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not enough info We need more information to properly assist with this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants