fix(tables): stop URL linkification at delimiters, not whitespace - #10570
Open
Abdulrehman-PIAIC80387 wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Contributor
|
@mscolnick I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Architecture diagram
sequenceDiagram
participant UI as Data Table / JSON Viewer
participant LP as Link Parser (url-parser.ts)
participant JVP as JSON Value Parser (json-parser.ts)
participant CT as Column Transformer (columns.tsx)
Note over UI, CT: Runtime flow when rendering table cells or JSON viewer content
UI->>CT: render cell(value)
alt Cell is a table column
CT->>LP: parseContent(textContent)
LP->>LP: Extract URLs with safe delimiter regex<br/>([^\s"'<>`{}|\\^]+)
LP-->>CT: Parts array (text + url objects)
CT-->>UI: Rendered cell with links
else Cell is JSON viewer content
CT->>JVP: formatValueForMarkdown(jsonValue)
JVP->>JVP: Convert plain URLs to markdown links<br/>using same safe delimiter regex
JVP->>JVP: Apply markdown link replacement
JVP-->>CT: Markdown string with links
CT-->>UI: Rendered JSON viewer
end
Note over LP, JVP: Shared linkification behavior
Note over LP: Regex stops at delimiters: " ' < > ` { } | \ ^
Note over JVP: Same regex applied consistently
Note over LP, JVP: Preserves valid URL chars: . , ( ) [ ] and query strings
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The table cell linkifier matched URLs with `https?://\S+`, so a URL embedded in JSON text (e.g. `..."url":"https://example.com/p/AAA"}]`) had the trailing `"}]` delimiters swallowed into the href, producing a broken link like `https://example.com/p/AAA%22%7D]`. Match a URL up to the first character that cannot appear unencoded in a URL (the RFC 3986 excluded/"unwise" set: whitespace and `" ' < > ` { } | \ ^`) instead of any non-whitespace. Characters that are valid in real URLs (`. , ( ) [ ]` etc.) are intentionally kept, so query strings, IPv6 hosts, and parenthesised paths are not truncated. Applied to the same greedy regex in the JSON-viewer link conversion as well. Closes marimo-team#10567
…ests Address review: - Extract the URL character-class regex into a single exported `URL_REGEX` in url-parser.ts; json-parser.ts derives its global copy via `new RegExp(URL_REGEX.source, "g")`, so the two linkifiers can't drift. - Add json-parser tests for `jsonToMarkdown`: a URL followed by `"}]` stops at the quote, a trailing quote isn't swallowed, and existing markdown links are left untouched.
Abdulrehman-PIAIC80387
force-pushed
the
fix/table-url-linkification-greedy-10567
branch
from
August 18, 2026 06:27
dc4435c to
bf21df6
Compare
for more information, see https://pre-commit.ci
Abdulrehman-PIAIC80387
marked this pull request as ready for review
August 18, 2026 12:30
Member
|
I think would be good to add a benchmark test, regexes like this have a chance to be slow. |
Member
|
Thanks @Abdulrehman-PIAIC80387 for the PR. |
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.
📝 Summary
Closes #10567
The table-cell URL linkifier matched URLs with
https?://\S+, so a URL embedded in JSON text had the trailing"}]delimiters swallowed into the href.The rendered link pointed at
https://example.com/p/AAA%22%7D](the"}]percent-encoded into the href) instead ofhttps://example.com/p/AAA.🔍 Root cause
frontend/src/utils/url-parser.ts(the table linkifier used bydata-table/columns.tsx):\S+matches any non-whitespace, so with no whitespace before the closing"}]it keeps consuming those delimiters.🔧 What changed
Match a URL up to the first character that cannot appear unencoded in a URL (RFC 3986 excluded/"unwise" set — whitespace and
" ' < > \{ } | \ ^`) instead of any non-whitespace:json/json-parser.ts(the JSON-viewer link conversion), which had the identical bug.. , ( ) [ ]etc. valid — real URLs use them (query strings, IPv6 hosts likehttp://[::1]/, parenthesised paths), so they must not truncate the match.urls.ts's^(https?://\S+)$alone — it's an anchored whole-stringisUrl()check where\S+is correct.🎥 Demo
clean-link.mp4
Shows the
attachmentscell: before, "Copy Link Address" yieldshttps://example.com/p/AAA%22%7D]; after, it yields the cleanhttps://example.com/p/AAA.🧪 Testing
url-parser.test.tsfor the reporter's JSON case and a trailing-quote case.\S+makes the new tests fail.data-tableconsumer tests (url-detector,columns) — 87 pass, no regressions.make fe-check(typecheck + lint) clean.make dev(before/after link address as above).📋 Pre-Review Checklist
✅ Merge Checklist