René's URL Explorer Experiment


Title: Avoid quadratic-time parsing for inline HTML · Issue #447 · commonmark/commonmark-java · GitHub

Open Graph Title: Avoid quadratic-time parsing for inline HTML · Issue #447 · commonmark/commonmark-java

X Title: Avoid quadratic-time parsing for inline HTML · Issue #447 · commonmark/commonmark-java

Description: Summary Every < in a document makes the inline parser look for the end of the construct it might start, and the scan is thrown away when that end is not there. On input made of < whose construct never ends, each one walks to the end of t...

Open Graph Description: Summary Every < in a document makes the inline parser look for the end of the construct it might start, and the scan is thrown away when that end is not there. On input made of < whose construct ne...

X Description: Summary Every < in a document makes the inline parser look for the end of the construct it might start, and the scan is thrown away when that end is not there. On input made of < whose constr...

Opengraph URL: https://github.com/commonmark/commonmark-java/issues/447

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Avoid quadratic-time parsing for inline HTML","articleBody":"### Summary\n\nEvery `\u003c` in a document makes the inline parser look for the end of the construct it might start, and the scan is thrown away when that end is not there. On input made of `\u003c` whose construct never ends, each one walks to the end of the input, so parsing is quadratic in the size of the input. Roughly 800 KB of `x \u003c!-- >` keeps a core busy for over a minute, so a single request can stall a worker in any application that renders untrusted Markdown (comments, chat, wikis).\n\n### Details\n\n[`HtmlInlineParser`](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java) is triggered by `\u003c` and has four scans of this shape:\n\n| Construct | Looks for | Code |\n|---|---|---|\n| processing instruction | `?>` | [L153](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L153) |\n| comment | `-->` | [L177](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L177) |\n| CDATA section | `]]>` | [L196](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L196) |\n| declaration | `>` | [L215](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L215) |\n\nEach of them ends up in [`Scanner.find`](https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/parser/beta/Scanner.java#L196), which advances one character at a time and only gives up at the end of the input:\n\n```java\nwhile (scanner.find('-') >= 0) {   // no `-->` ahead, so this walks to the end of the input\n    if (scanner.next(\"-->\")) {\n        return true;\n    } else {\n        scanner.next();\n    }\n}\n```\n\nThe candidate is then rejected, the position is reset, and the next `\u003c` starts the same scan over again. With n openers that is n scans of average length n/2. Plain paragraph text is enough to reach it:\n\n| Input, repeated | Size at 100,000 | 25,000 | 50,000 | 100,000 | 100,000 with the patch |\n|---|---|--:|--:|--:|--:|\n| `x \u003c? >` | 586 KB | 1.7 s | 6.6 s | 26.7 s | 0.08 s |\n| `x \u003c!-- >` | 781 KB | 4.6 s | 19.2 s | 76.7 s | 0.07 s |\n| `x \u003c![CDATA[ >` | 1270 KB | 3.5 s | 15.3 s | 63.0 s | 0.13 s |\n\nMeasured with `Parser.builder().build()` and `HtmlRenderer.builder().build()` on JDK 25, current `main` (`7a68e920`). Times roughly quadruple when the input doubles.\n\nEach payload deliberately contains a `>` close to every `\u003c`, so that the separately reported autolink scan for `>` stays cheap and only the inline HTML scanning is measured. It also starts with text so the line doesn't begin with `\u003c`, which would parse as an HTML block instead.\n\nA PR will shortly follow.\n\n### Credits\n\nFound by [Team Atlanta](https://team-atlanta.github.io/).  \nCollected and verified by [OSTIF](https://ostif.org) using AI with their own harness.  \nManually verified, fixed, and reported by [Shielder](https://www.shielder.com).","author":{"url":"https://github.com/fromVeeko","@type":"Person","name":"fromVeeko"},"datePublished":"2026-08-05T16:28:16Z","url":"https://github.com/commonmark/commonmark-java/issues/447"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:24953c6e-e6ef-9c9f-a46e-d81ec9acf846
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id833C:2E0E94:2DCC97:3E12AE:6AFBB232
html-safe-nonce8b548c06e48f83201024383fe4d0c88feddc1283672c332fec7d5cf1b1d41c36
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzNDOjJFMEU5NDoyRENDOTc6M0UxMkFFOjZBRkJCMjMyIiwidmlzaXRvcl9pZCI6IjM5MDMyMzczMDIyNTUzMzM5MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfc9f0acf71e997998d5b4a285b46db059d7fd9edcf64bbc4896f16ff37476d6b
hovercard-subject-tagissue:5073060653
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commonmark/commonmark-java/447/issue_layout
twitter:imagehttps://opengraph.githubassets.com/81109a52dc42910bfe342a73011f63c2d5a2d343e58aa3fd2ccb78f374bc21aa/commonmark/commonmark-java/issues/447
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/81109a52dc42910bfe342a73011f63c2d5a2d343e58aa3fd2ccb78f374bc21aa/commonmark/commonmark-java/issues/447
og:image:altSummary Every < in a document makes the inline parser look for the end of the construct it might start, and the scan is thrown away when that end is not there. On input made of < whose construct ne...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefromVeeko
hostnamegithub.com
expected-hostnamegithub.com
None2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c
turbo-cache-controlno-preview
go-importgithub.com/commonmark/commonmark-java git https://github.com/commonmark/commonmark-java.git
octolytics-dimension-user_id8661225
octolytics-dimension-user_logincommonmark
octolytics-dimension-repository_id39477878
octolytics-dimension-repository_nwocommonmark/commonmark-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id39477878
octolytics-dimension-repository_network_root_nwocommonmark/commonmark-java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee4cce0e99cf61481a318ff12c2e8580153a6c7c6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/commonmark/commonmark-java/issues/447#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommonmark%2Fcommonmark-java%2Fissues%2F447
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommonmark%2Fcommonmark-java%2Fissues%2F447
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=commonmark%2Fcommonmark-java
Reloadhttps://github.com/commonmark/commonmark-java/issues/447
Reloadhttps://github.com/commonmark/commonmark-java/issues/447
Reloadhttps://github.com/commonmark/commonmark-java/issues/447
commonmarkhttps://github.com/commonmark
commonmark-javahttps://github.com/commonmark/commonmark-java
Codehttps://github.com/commonmark/commonmark-java
Issues9 (9)https://github.com/commonmark/commonmark-java/issues
Pull requests4 (4)https://github.com/commonmark/commonmark-java/pulls
Actionshttps://github.com/commonmark/commonmark-java/actions
Wikihttps://github.com/commonmark/commonmark-java/wiki
Security and quality8 (8)https://github.com/commonmark/commonmark-java/security
Insightshttps://github.com/commonmark/commonmark-java/pulse
https://github.com/commonmark/commonmark-java
New issuehttps://github.com/login?return_to=https://github.com/commonmark/commonmark-java/issues/447
New issuehttps://github.com/login?return_to=https://github.com/commonmark/commonmark-java/issues/447
Avoid quadratic-time parsing for inline HTMLhttps://github.com/commonmark/commonmark-java/issues/447#top
bughttps://github.com/commonmark/commonmark-java/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/fromVeeko
fromVeekohttps://github.com/fromVeeko
on Aug 5, 2026https://github.com/commonmark/commonmark-java/issues/447#issue-5073060653
HtmlInlineParserhttps://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java
L153https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L153
L177https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L177
L196https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L196
L215https://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/internal/inline/HtmlInlineParser.java#L215
Scanner.findhttps://github.com/commonmark/commonmark-java/blob/7a68e9204c8f4e521f8206aff3b64361e1a605b1/commonmark/src/main/java/org/commonmark/parser/beta/Scanner.java#L196
Team Atlantahttps://team-atlanta.github.io/
OSTIFhttps://ostif.org
Shielderhttps://www.shielder.com
fromVeekohttps://github.com/fromVeeko
bughttps://github.com/commonmark/commonmark-java/issues?q=state%3Aopen%20label%3A%22bug%22
on Aug 5, 2026https://github.com/commonmark/commonmark-java/issues/447#event-29021317542
robinsthttps://github.com/robinst
completedhttps://github.com/commonmark/commonmark-java/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
946b6c5https://github.com/commonmark/commonmark-java/commit/946b6c5e63a82d324f00b0f78cd39a401bbd127c
on Aug 6, 2026https://github.com/commonmark/commonmark-java/issues/447#event-29041017227
robinsthttps://github.com/robinst
on Aug 6, 2026https://github.com/commonmark/commonmark-java/issues/447#event-29041017409
Merge pull request #448 from fromVeeko/fix/avoid-quadratic-time-compl…https://github.com/commonmark/commonmark-java/commit/f06a01d37a47b2134c3806692b7d395ba574e835
#448https://github.com/commonmark/commonmark-java/pull/448
f06a01dhttps://github.com/commonmark/commonmark-java/commit/f06a01d37a47b2134c3806692b7d395ba574e835
robinsthttps://github.com/robinst
on Aug 6, 2026https://github.com/commonmark/commonmark-java/issues/447#event-29041043117
https://github.com/robinst
robinsthttps://github.com/robinst
on Aug 6, 2026https://github.com/commonmark/commonmark-java/issues/447#issuecomment-5204033652
https://github.com/commonmark/commonmark-java/blob/main/CHANGELOG.md#0300---2026-08-06https://github.com/commonmark/commonmark-java/blob/main/CHANGELOG.md#0300---2026-08-06
priandhttps://github.com/priand
on Aug 17, 2026https://github.com/commonmark/commonmark-java/issues/447#event-29574876428
fix commonmark#447https://github.com/monflabs-forks/commonmark-java/commit/946b6c5e63a82d324f00b0f78cd39a401bbd127c
commonmark#447https://github.com/commonmark/commonmark-java/issues/447
https://docs.github.com/articles/closing-issues-via-commit-messages
946b6c5https://github.com/monflabs-forks/commonmark-java/commit/946b6c5e63a82d324f00b0f78cd39a401bbd127c
Sign up for freehttps://github.com/signup?return_to=https://github.com/commonmark/commonmark-java/issues/447
Sign in to commenthttps://github.com/login?return_to=https://github.com/commonmark/commonmark-java/issues/447
bughttps://github.com/commonmark/commonmark-java/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.