Repository navigation
Older Safari (before 16.4): Admin, most pages and Markdown replies draw again - #2930
Merged
Merged
Conversation
Safari 16.0 to 16.3, and OpenBot Desktop on macOS before 13.3, can't read
a regular expression lookbehind. The build targets Safari 16.0 and turns
each one into new RegExp("..."), so it threw when its chunk ran: every
Admin page and most app pages showed "This page couldn't be shown", and
every Markdown reply and document failed to draw.
Rewrite the eight lookbehinds in the app without one, with the same
output, and replace GitHub-flavoured Markdown's email finder in the build
with one that finds the same matches as quickly. Set build.target to the
Safari 16.0 floor explicitly. A test reads every regular expression in
the built chunks and fails on anything Safari 16.0 can't compile, and
loads Admin, Apps and a document under Safari 16.0's regex rules in
Chromium and WebKit.
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 4, 2026 10:40
9 tasks done
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.
What this changes
In Safari 16.0 to 16.3, and in OpenBot Desktop on a Mac older than macOS 13.3 (its window draws with the Mac's own Safari), every Admin page and most of the app's pages showed "This page couldn't be shown". Every reply in Markdown and every document failed to draw as well. Chat's shell still loaded.
Cause. Regular expressions with a lookbehind (
(?<=or(?<!). WebKit reads them only from Safari 16.4. The app is built for Safari 16.0 (Vite's default), so the build turns each such literal intonew RegExp("…"). The chunk still parses, and the error comes when the code runs:SyntaxError: Invalid regular expression: invalid group specifier name. Desktop shows the same error asReferenceError: Cannot access uninitialized variable(WebKit bug 190843). The one that broke Admin is in the tool words (BY_ITS_ID), which compiled as its chunk loaded. It has been there since v0.3.4.Every lookbehind the build ships, now without one, with the same output:
lib/plugins/tool-words.ts:BY_ITS_ID("sorted by ID" is not "by its ID"). It now finds the match first and checks the word before "by". A refused match resumes one character on, the way the engine moves past a refused lookbehind.lib/maths.ts:$inside a formula.lib/tasks/line.ts:|.components/audit/audit-cells.tsx: the break points in an identifier.lib/boundaries/rules.ts: a rule's sentences. This one wasn't in the triage; the bundle scan found it./(?<=^|\s|\p{P}|\p{S})…/guruns on every Markdown parse.src/lib/markdown-email-links.ts, aRegExpwhoseexecreturns the same match from anylastIndex.Nothing else in the build uses a newer regular-expression feature. No other app code does either: no
vflag, no group name used twice, no modifiers. Underdesktop/src, lookbehinds appear only in tests. marked compiles one inside atryas a feature test and falls back, so it stays.Also changed:
app/vite.config.tsnow setsbuild.targetexplicitly, to Vite's own default: Chrome and Edge 107, Firefox 104, Safari 16. The floor stays where it was, but it is now written down.acorn8.19.0 and@eslint-community/regexpp4.12.3, both used only by the test.How the leaders guard this, and what this does. Two kinds of check are in common use:
eslint-plugin-es-x'sno-regexp-lookbehind-assertions(docs), often run through browserslist presets. It reads only our own source, so it would miss the mdast lookbehind. This repo also lints with Biome, not ESLint.--checkBrowserwith browserslist) and Rsbuild's check-syntax. es-check says outright that "strings passed to theRegExpconstructor are not parsed as regular expression source". The build turns every lookbehind into exactly that, so it would miss all nine.So this follows the bundle-checking approach, built from the same widely used parts. The test parses every built chunk with acorn and reads each regex literal and each
RegExp("…")with@eslint-community/regexpp, the parser ESLint itself uses. It fails on anything Safari 16.0 can't compile.Where it runs
In the browser only. No server state, no new listener.
Boundary and audit
API and database
api/, no app's requests, no database change and norelease-policy.json.Changelog
Fixed.
Proof
app/tests/older-safari-build.test.tsbuilds the app as it ships. A run onmainfails 7 of 7 tests; this branch passes 7 of 7. It checks:mainit lists the nine regular expressions above, with their chunks. On this branch it lists none.RegExpconstructor refuses a lookbehind with WebKit's own message before any page code runs. The pages are an Admin page (People), an app page (Apps), and a public document containing an email address and two formulas.main: People and Apps show "This page couldn't be shown" with the SyntaxError. The document shows "This artifact couldn't be shown".mailto:link and both formulas are KaTeX.app/tests/older-safari-same-words.test.tsholds each rewrite to the lookbehind it replaces, on a current engine.\$,\|,a__b, astral characters before an address), then a few thousand seeded strings per rule.lastIndex, which is how mdast-util-find-and-replace calls it.No visual change. The
mainbuild and this build were screenshotted in WebKit and Chromium, light and dark, on Admin People, Admin Activity (identifier breaks), Apps and the document, with no shim and the same API answers. All 16 pairs are pixel-identical.Checks run:
tscfor the app and the workbench.scripts/ci-changes.test.ts.ci.yml, next totrusted-types-build.