Repository navigation
Conversation
📝 Walkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6399f9d to
f988ae5
Compare
|
Thanks for this — the writeup, the benchmark table, and the security notes are unusually careful, and I dug in properly because of it. Heads up first: I have not pushed anything to your branch. The short version is that the You were circling something real, though. That regex is looser than BCP-47, and that's the direction that bites: shape-legal typos like The fix for it is small and sits one layer up: a single Would you like to repurpose this PR to that, or would you rather we carry it? Genuinely your call — you found the gap. One more thing worth a look: #12505 is stacked on this branch, so it may rest on the same premise. |
f988ae5 to
2f064a0
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Repurposed as you suggested — taking it, since you offered. The PR body has the full writeup; short version below.
One measurement I'd flag before you review. I bucketed every tag the current schema accepts by what
This PR closes the 22%. The 61% is well-formed-but-unknown tags — they pass That's the half #12505 covers, so I don't think it rests on the same premise — its claim is that the synthetic Also out of scope but noted in the body: the regex is narrower than BCP 47 in places too — |
`pluginLocaleIdSchema` checks the shape of a locale id but not its grammar, and the shape check is looser than BCP 47 in one direction: `en-US-US` (duplicate region) and `en-aaa` (a subtag that is neither region nor script) both match it. A pack declaring one installs, loads, and translates every string — and then `Intl.DateTimeFormat` throws inside `getIntlLocale()`, which swallows the error and falls back to English. Nothing is logged, so the pack author sees a working pack with English dates and no way to tell why. Delegate the grammar to `Intl.getCanonicalLocales` in a `.refine`, so the tag is rejected at install where the author can still act on it. The bundled `pt-BR` pack and every other well-formed tag are unaffected.
2f064a0 to
f69dc01
Compare
|
Gentle nudge — no rush intended, I know the queue is deep. This has been sitting green since 8 Aug: repurposed to the Two things downstream of your call on it, whenever you get to it: #12505 needs a rebase either way, since it imports A second narrow widening of the plugin-chrome exemption is written and tested locally — 23 paths, the install form and the log controls, following the same rule as #12455. I'm holding it rather than opening a third PR into the same area while these two are open. Happy to keep holding it, or to open it, whichever is less noise for you. And if the direction here has changed or this dropped down the list, just say so — I'd rather know than keep it warm. |
Summary
Repurposed from canonicalizing the locale at read time to rejecting it at install, per review.
pluginLocaleIdSchemachecks the shape of a locale id, not its grammar, and the shape check is looser than BCP 47 in one direction:en-US-US(duplicate region) anden-aaa(a subtag that is neither a region nor a script) both match/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.A pack declaring one installs cleanly, loads, and translates every string. Then
Intl.DateTimeFormatthrows insidegetIntlLocale(), thecatchatsrc/renderer/src/i18n/i18n.ts:106-113swallows it, and dates and relative times fall back to English with nothing logged. The pack author sees a working pack with English dates and no way to tell why.The fix is one
.refineon the schema delegating the grammar toIntl.getCanonicalLocales, so the tag is rejected at install where the author can still act on it. No new module, no cache, no renderer change. The bundledpt-BRpack is unaffected, as is every other well-formed tag.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test—src/shared/pluginsgreen at 147 tests; the 8 unrelated files that fail here fail identically on a cleanupstream/maincheckout (Node 26 against the required Node 24:node-ptyABI and timing-sensitive watchers)pnpm builden-US-US,en-aaa) alongside the existingen_UScase, and a positive case pinningru,pt-BR,zh-Hans-CN,en-USso the refine cannot start rejecting real packsAI Review Report
Reviewed for scope, blast radius, and cross-platform behavior.
pluginLocaleIdSchemahas exactly one consumer,pluginLanguagePackContributionSchema; grep acrosssrc/confirms no other import. Nothing outside manifest parsing changes.pt-BR(bundled),ru,en-US,zh-Hans-CN,ja,ko,es. All pass. The added positive test pins four of them so a future tightening cannot silently break them.Intl.getCanonicalLocalesis ECMA-402, present in every Node and Chromium build this project targets; no platform branch, no path handling, no shell, no shortcut or label. Verified the behaviour is identical under the repo's Node 24 target and the Node 26 used locally. Nothing Electron-specific is touched.Intlcannot parse are now rejected at parse time instead of loading and failing silently later. No previously-valid tag becomes invalid.Security Audit
.refineruns after it.Intl.getCanonicalLocalesthrowsRangeErroron malformed input; the helper catches and returnsfalserather than letting it escape into manifest parsing. It catches everything deliberately — any throw from this call means the tag is unusable.Intlis a language built-in.Notes
One measurement worth flagging. I bucketed every tag the current schema accepts by what
Intldoes with it — all two-letter primary subtags against typical second subtags (regions, scripts, and shape-legal fakes of both):Intlthrows — caught by this PRen-US-US,en-aaaxx,aa-US,zz-ZZaf,pt-BRThis PR closes the 22%. The 61% is well-formed-but-unknown tags: they pass
getCanonicalLocales, the pack loads, andIntl.PluralRules.supportedLocalesOfreturns empty — same silent English fallback, different cause..refinestructurally cannot catch those, because the grammar is valid.That is the half #12505 addresses, which is why I don't think it rests on the same premise. Its core claim — the synthetic
plugin<hex>language never gets plural rules regardless of how valid the declared locale is — holds after this change. It currently importscanonicalizePackLocale, which this PR removes, so I'll rebase it off this branch once the direction here is settled.Separately and out of scope: the regex is also narrower than BCP 47 in places.
en-US-u-ca-buddhistanden-a-bbbare legal but rejected, because a single-letter extension singleton doesn't fit{2,8}. Happy to open that separately if it's worth having.