Skip to content

Commit e93f815

Browse files
authored
Prevent plugin host localization errors (#15268)
1 parent abae333 commit e93f815

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/plugin-ext/src/hosted/node/hosted-plugin-localization-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ function coerceLocalizations(translations: Record<string, string | LocalizeInfo>
379379
function localizePackage(value: unknown, translations: PackageTranslation, callback: (key: string, defaultValue: string) => string): unknown {
380380
if (typeof value === 'string') {
381381
let result = value;
382-
if (value.startsWith('%') && value.endsWith('%')) {
382+
if (value.length > 2 && value.startsWith('%') && value.endsWith('%')) {
383383
const key = value.slice(1, -1);
384-
if (translations.translation) {
384+
if (translations.translation && key in translations.translation) {
385385
result = translations.translation[key];
386-
} else if (translations.default) {
386+
} else if (translations.default && key in translations.default) {
387387
result = callback(key, translations.default[key]);
388388
}
389389
}

0 commit comments

Comments
 (0)