Repository navigation
fix: drop regex lookbehind in GFM autolink to fix legacy-WebKit white screen - #27
Merged
Merged
Conversation
mdast-util-gfm-autolink-literal@2.0.1 uses a lookbehind assertion in its email autolink regex. Legacy WebKit engines (Safari < 16.4, e.g. the WKWebView on macOS 12) cannot compile lookbehind, and since regex literals compile at module parse time the whole frontend bundle failed to parse, rendering a blank screen in ACECode desktop. Patch the dependency to remove the lookbehind: findEmail already re-validates the preceding character at runtime via previous(match, true), so behavior is unchanged (covered by new regression tests). Also add scripts/check-regex-compat.mjs to the build so any future lookbehind regex literal in the bundle fails the build instead of blank-screening legacy WebKit users at runtime.
LIUXIN557
force-pushed
the
bugfix/webkit-lookbehind-autolink
branch
from
August 30, 2026 16:02
ae4cccc to
ce3f902
Compare
shaohaozhi286
approved these changes
Aug 31, 2026
shaohaozhi286
left a comment
Collaborator
There was a problem hiding this comment.
批准合入。
lookbehind 从 pnpm patch 去掉是对症的:legacy WebKit 在 parse 阶段就编译 regex literal,单条就能让整个 bundle 白屏。findEmail 里现有的 previous(match, true) 能接住前置字符校验,7 个 autolink 回归用例也覆盖了常见边界。
check-regex-compat.mjs 扫 dist/index.html 在这个仓库里是成立的:vite-plugin-singlefile 把 JS 全部 inline 进 html。pnpm build 后挂这个检查能挡住以后新的 lookbehind。
顺带:PR 描述里写了 agent_browser_host_mac.mm 的 LOG_* 括号修复,但这两个 commit 里没有这个文件。不影响本次修复。
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
(?<=...)(frommdast-util-gfm-autolink-literal@2.0.1's email autolink pattern). Lookbehind requires Safari 16.4+, but on macOS 12 the WKWebView / JavaScriptCore engine is pinned to Safari 15.6. The whole bundle failed to parse at load time, React never mounted, and the desktop main window rendered a white screen. Chrome (much newer engine) rendered normally, confirming the engine-version gap.mdast-util-gfm-autolink-literal@2.0.1. ThefindEmailcallback already runs a runtimeprevious(match, true)check that validates the preceding character, so dropping the lookbehind keeps valid email autolinking identical while letting the bundle compile on Safari 15.6-class engines.web/src/lib/gfmAutolinkCompat.test.js(7 cases) andweb/scripts/check-regex-compat.mjs, wired intopnpm buildto fail the build if anydistregex literal still uses lookbehind.src/desktop/agent_browser_host_mac.mmhad 10LOG_*macro calls whose bracedjson{...}argument was being split on commas. Parenthesized the argument so the macOS desktop target compiles. (Required to actually ship the rebuilt desktop app on macOS.)Test plan
pnpm install && pnpm buildinweb/— passes the regex-compat check.new Function(bundle)syntax check passes on macOS 12 (noInvalid regular expression).Impact / follow-ups
mdast-util-gfm-autolink-literalis upgraded past the lookbehind usage.