Repository navigation
fix: allow non-ASCII letters everywhere in a GFM autolink host (IJPL-91081) - #229
Closed
jetbrains-air[bot] wants to merge 2 commits into
Closed
jetbrains-air[bot] wants to merge 2 commits into
jetbrains-air[bot] wants to merge 2 commits into
Conversation
…91081) HOST_PART accepted a Unicode letter only as the first or last character of a host segment, so `https://www.jetbrains.com에서` was lexed as an autolink ending after a single Korean letter (`…com에`), splitting the following word in the middle, and Unicode domains were cut short. Now the whole segment is Unicode-aware, matching cmark-gfm, which accepts any non-space non-punctuation character in a domain. Produced by Air Automations. Name: Markdown library: fix the bug / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/cb6a17f6-e7a9-41a8-9611-7c95c4eb0141?run=78ebdf41-2c32-4f98-a7d7-10425f900ab9 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Peter Gromov (donnerpeter)
approved these changes
Sep 25, 2026
Member
|
Merged manually |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the remaining library-side defect behind IJPL-91081 "Markdown: Link does not render properly".
Investigation
The repro reported in the issue and its comments — an inline link followed immediately by letters, e.g.
Check [here](https://www.jetbrains.com/)asdfor[여기](https://www.jetbrains.com/)에서 확인하세요.— no longer reproduces at HEAD: it was fixed back in 0.2.1 by the autolink pushback logic (pushbackAutolink()in_GFMLexer). Verified for all samples from the issue, its screenshots, and the linked gist, with both the batch and the streaming parser.What is still broken at HEAD is the same user scenario with a bare GFM autolink.
HOST_PARTwas defined asi.e. a Unicode letter was accepted only as the first or last character of a host segment, while the interior was ASCII-only. Consequences:
https://www.jetbrains.com에서 확인lexed as autolinkhttps://www.jetbrains.com에+ text서 확인— exactly one Korean letter absorbed into the host, the following word split in the middle, and a click leads to a wrong URL (the reported symptom).https://例え.テスト/linked onlyhttps://例え.Fix
Make the whole host segment Unicode-aware:
This matches the GFM reference implementation: cmark-gfm's
check_domain/is_valid_hostcharaccepts any non-space, non-punctuation character in a domain, so github.com linkshttps://www.jetbrains.com에서as one unit and never splits a word after the domain. ASCII behavior is unchanged (full CommonMark + GFM spec suites pass).The checked-in
_GFMLexer.ktwas regenerated with JFlex 1.9.2 (IntelliJ fork) andidea-flex.skeleton. The toolchain was validated by first regenerating from the unmodifiedgfm.flexand confirming all packed DFA tables matched the checked-in file exactly; the fix then only changes the four DFA tables (686 → 683 states) — character maps and action code are untouched.Note:
sfm.flexhas the sameHOST_PARTpattern, but was deliberately left unchanged — SFM autolinks are TLD-based and changing their Unicode handling is a separate, riskier decision.Verification
GfmTestcover the issue's inline-link repro (English + Korean) and the bare-autolink cases (Korean word after domain, Unicode domain).jvmTest: 1553 tests pass, 0 failures (includes CommonMark and GFM spec suites and file-based HTML tests).jsNodeTest: passes.Produced by Air Automations. Name: Markdown library: fix the bug / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/cb6a17f6-e7a9-41a8-9611-7c95c4eb0141?run=78ebdf41-2c32-4f98-a7d7-10425f900ab9
🤖 Generated with Claude Code