vue-i18n 11.4.18 → 11.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-i18n.cjs +2 -2
- package/dist/vue-i18n.d.ts +8 -2
- package/dist/vue-i18n.esm-browser.js +169 -37
- package/dist/vue-i18n.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.global.js +169 -37
- package/dist/vue-i18n.global.prod.js +2 -2
- package/dist/vue-i18n.mjs +2 -2
- package/dist/vue-i18n.node.mjs +2 -2
- package/dist/vue-i18n.prod.cjs +2 -2
- package/dist/vue-i18n.runtime.esm-browser.js +169 -37
- package/dist/vue-i18n.runtime.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.runtime.global.js +169 -37
- package/dist/vue-i18n.runtime.global.prod.js +2 -2
- package/dist/vue-i18n.runtime.mjs +2 -2
- package/dist/vue-i18n.runtime.node.mjs +2 -2
- package/package.json +4 -4
package/dist/vue-i18n.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v11.4.
|
|
2
|
+
* vue-i18n v11.4.19
|
|
3
3
|
* (c) 2026 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -30,7 +30,7 @@ var Vue__namespace = /*#__PURE__*/_interopNamespaceDefault(Vue);
|
|
|
30
30
|
*
|
|
31
31
|
* @VueI18nGeneral
|
|
32
32
|
*/
|
|
33
|
-
const VERSION = '11.4.
|
|
33
|
+
const VERSION = '11.4.19';
|
|
34
34
|
|
|
35
35
|
const I18nErrorCodes = {
|
|
36
36
|
// composer module errors
|
package/dist/vue-i18n.d.ts
CHANGED
|
@@ -885,11 +885,14 @@ export declare interface ComposerOptions<Schema extends {
|
|
|
885
885
|
* When enabled, this option:
|
|
886
886
|
* - Escapes HTML special characters (`<`, `>`, `"`, `'`, `&`, `/`, `=`) in interpolation parameters
|
|
887
887
|
* - Sanitizes the final translated HTML to prevent XSS attacks by:
|
|
888
|
+
* - Reading tags and attributes in the same way as the HTML parser of browsers, so that every attribute is checked
|
|
888
889
|
* - Escaping dangerous characters in HTML attribute values
|
|
889
890
|
* - Neutralizing event handler attributes (onclick, onerror, etc.)
|
|
890
891
|
* - Neutralizing the `srcdoc` attribute of `<iframe>`
|
|
891
|
-
* - Neutralizing `<base>` and `<
|
|
892
|
+
* - Neutralizing `<base>`, `<script>` and `<plaintext>` elements, and SVG `<animate>` and `<set>` elements
|
|
892
893
|
* - Disabling javascript: URLs in href (and xlink:href of SVG), src, action, formaction, and style attributes
|
|
894
|
+
* - Escaping `<` in the content of `<textarea>`, `<title>`, `<style>`, `<iframe>` and similar elements
|
|
895
|
+
* - Turning a tag, a comment, or an element like `<textarea>` that is not closed at the end into text
|
|
893
896
|
*
|
|
894
897
|
* This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
|
|
895
898
|
*
|
|
@@ -2807,11 +2810,14 @@ export declare interface VueI18nOptions<Schema extends {
|
|
|
2807
2810
|
* When enabled, this option:
|
|
2808
2811
|
* - Escapes HTML special characters (`<`, `>`, `"`, `'`, `&`, `/`, `=`) in interpolation parameters
|
|
2809
2812
|
* - Sanitizes the final translated HTML to prevent XSS attacks by:
|
|
2813
|
+
* - Reading tags and attributes in the same way as the HTML parser of browsers, so that every attribute is checked
|
|
2810
2814
|
* - Escaping dangerous characters in HTML attribute values
|
|
2811
2815
|
* - Neutralizing event handler attributes (onclick, onerror, etc.)
|
|
2812
2816
|
* - Neutralizing the `srcdoc` attribute of `<iframe>`
|
|
2813
|
-
* - Neutralizing `<base>` and `<
|
|
2817
|
+
* - Neutralizing `<base>`, `<script>` and `<plaintext>` elements, and SVG `<animate>` and `<set>` elements
|
|
2814
2818
|
* - Disabling javascript: URLs in href (and xlink:href of SVG), src, action, formaction, and style attributes
|
|
2819
|
+
* - Escaping `<` in the content of `<textarea>`, `<title>`, `<style>`, `<iframe>` and similar elements
|
|
2820
|
+
* - Turning a tag, a comment, or an element like `<textarea>` that is not closed at the end into text
|
|
2815
2821
|
*
|
|
2816
2822
|
* This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
|
|
2817
2823
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v11.4.
|
|
2
|
+
* vue-i18n v11.4.19
|
|
3
3
|
* (c) 2026 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -209,19 +209,26 @@ const namedWhitespaceCharacterReferencePattern = /&(?:Tab|NewLine);/g;
|
|
|
209
209
|
const colonCharacterReferencePattern = /:?/gi;
|
|
210
210
|
// eslint-disable-next-line no-control-regex -- URL scheme normalization requires the full control range
|
|
211
211
|
const controlOrWhitespacePattern = /[\u0000-\u0020\u007f-\u009f]/g;
|
|
212
|
-
const eventHandlerPattern =
|
|
213
|
-
const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
|
|
212
|
+
const eventHandlerPattern = /^on\w/i;
|
|
214
213
|
// `srcdoc` holds a whole HTML document: its value is entity-decoded and then parsed again,
|
|
215
214
|
// so neither escaping the value nor neutralizing `on*` inside it makes it inert
|
|
216
|
-
const srcdocPattern =
|
|
217
|
-
const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
|
|
215
|
+
const srcdocPattern = /^srcdoc$/i;
|
|
218
216
|
// `<base>` changes how the page resolves every relative URL after it, and SVG `<animate>` and `<set>`
|
|
219
217
|
// can set `href` of an SVG `<a>` through `values` or `to`, which the URL check does not look at.
|
|
220
218
|
// `<script>` does not run when inserted with `innerHTML`, but it runs when the HTML is rendered
|
|
221
|
-
// on the server (SSR) and the browser parses it as part of the page
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
219
|
+
// on the server (SSR) and the browser parses it as part of the page.
|
|
220
|
+
// `<plaintext>` turns the rest of the page into text
|
|
221
|
+
const dangerousElementPattern = /^(?:base|animate|set|script|plaintext)$/i;
|
|
222
|
+
// The content of these elements is text up to their end tag when they are HTML elements, and markup when
|
|
223
|
+
// they are SVG or MathML elements. Their content is turned into text, so that it reads the same in both
|
|
224
|
+
const textContentElementPattern = /^(?:iframe|noembed|noframes|noscript|style|textarea|title|xmp)$/i;
|
|
225
|
+
// The rules of the HTML tokenizer for tags, comments, and the end of a tag that is not closed (`$`):
|
|
226
|
+
// - `<` or `</`, and the tag name
|
|
227
|
+
const tagStartPattern = /<(\/?)([a-z][^\t\n\f\r />]*)/iy;
|
|
228
|
+
// - whitespace and `/`, and then `>` or an attribute: its name, and its value in quotes or without quotes
|
|
229
|
+
const tagStepPattern = /([\t\n\f\r /]*)(?:(>)|([^\t\n\f\r />][^\t\n\f\r />=]*)(?:[\t\n\f\r ]*=[\t\n\f\r ]*(?:(["'])([\s\S]*?)(\4|$)|([^\t\n\f\r >]*)))?)/y;
|
|
230
|
+
// - a comment, which ends with `-->` or `--!>`, or with `>` or `->` right after `<!--`
|
|
231
|
+
const commentPattern = /<!--(?:>|->|[\s\S]*?--!?>)/y;
|
|
225
232
|
function decodeNumericCharacterReference(match, hex, decimal) {
|
|
226
233
|
const digits = hex || decimal;
|
|
227
234
|
if (!digits) {
|
|
@@ -293,42 +300,167 @@ function sanitizeAttributeValue(attrName, value) {
|
|
|
293
300
|
const sanitizedValue = attrName.toLowerCase() === 'style' ? sanitizeStyleValue(value) : value;
|
|
294
301
|
return escapeAttributeValue(sanitizedValue);
|
|
295
302
|
}
|
|
303
|
+
function escapeLessThan(text) {
|
|
304
|
+
return text.replace(/</g, '<');
|
|
305
|
+
}
|
|
306
|
+
function serializeAttribute(attrName, value, quote, neutralized) {
|
|
307
|
+
// Character references are not decoded in attribute names, so escaping a character renames the attribute
|
|
308
|
+
let name = attrName;
|
|
309
|
+
if (eventHandlerPattern.test(attrName)) {
|
|
310
|
+
neutralized.eventHandler = true;
|
|
311
|
+
name = `on${attrName.slice(2)}`;
|
|
312
|
+
}
|
|
313
|
+
else if (srcdocPattern.test(attrName)) {
|
|
314
|
+
neutralized.srcdoc = true;
|
|
315
|
+
name = `s${attrName.slice(1)}`;
|
|
316
|
+
}
|
|
317
|
+
if (value === undefined) {
|
|
318
|
+
return name;
|
|
319
|
+
}
|
|
320
|
+
// An unquoted value stays unquoted: it has no whitespace or `>`, and escaping does not add them
|
|
321
|
+
const valueQuote = quote || '';
|
|
322
|
+
return `${name}=${valueQuote}${sanitizeAttributeValue(attrName, value)}${valueQuote}`;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Read a tag with the rules of the HTML tokenizer.
|
|
326
|
+
* A start tag is written again with its attributes sanitized, and an end tag is kept as it is
|
|
327
|
+
*
|
|
328
|
+
* @param html - The HTML
|
|
329
|
+
* @param start - The index of `<`
|
|
330
|
+
* @param neutralized - What has been neutralized
|
|
331
|
+
* @returns The tag, the tag name, and the index after the tag (-1 when the tag is not closed),
|
|
332
|
+
* or `undefined` when `<` does not start a tag
|
|
333
|
+
*/
|
|
334
|
+
function readTag(html, start, neutralized) {
|
|
335
|
+
tagStartPattern.lastIndex = start;
|
|
336
|
+
const tagStart = tagStartPattern.exec(html);
|
|
337
|
+
if (!tagStart) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const [, slash, tagName] = tagStart;
|
|
341
|
+
let tag = tagStart[0];
|
|
342
|
+
let step;
|
|
343
|
+
tagStepPattern.lastIndex = tagStartPattern.lastIndex;
|
|
344
|
+
while ((step = tagStepPattern.exec(html))) {
|
|
345
|
+
const [raw, separator, close, attrName, quote, quotedValue, closingQuote, unquotedValue] = step;
|
|
346
|
+
if (close) {
|
|
347
|
+
const end = tagStepPattern.lastIndex;
|
|
348
|
+
// browsers ignore the attributes of end tags
|
|
349
|
+
return [slash ? html.slice(start, end) : tag + raw, tagName, end];
|
|
350
|
+
}
|
|
351
|
+
if (quote && !closingQuote) {
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
if (!slash) {
|
|
355
|
+
const value = quote ? quotedValue : unquotedValue;
|
|
356
|
+
tag += separator + serializeAttribute(attrName, value, quote, neutralized);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return [tag, tagName, -1];
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Find the end tag of an element whose content is text, as the HTML tokenizer does:
|
|
363
|
+
* the first `</` followed by the tag name, and by whitespace, `/` or `>`
|
|
364
|
+
*
|
|
365
|
+
* @returns The index of the end tag, or -1 when it is not found or not closed in the string
|
|
366
|
+
*/
|
|
367
|
+
function findTextContentEnd(html, from, tagName) {
|
|
368
|
+
for (let index = html.indexOf('</', from); index !== -1; index = html.indexOf('</', index + 2)) {
|
|
369
|
+
const endTag = readTag(html, index, {});
|
|
370
|
+
if (endTag && endTag[1].toLowerCase() === tagName.toLowerCase()) {
|
|
371
|
+
return endTag[2] === -1 ? -1 : index;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return -1;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Sanitize the translated HTML
|
|
378
|
+
*
|
|
379
|
+
* @remarks
|
|
380
|
+
* Tags are read with the rules of the HTML tokenizer, so that the sanitizer and browsers agree on
|
|
381
|
+
* where each tag and each attribute starts and ends, and every attribute of every start tag is checked.
|
|
382
|
+
* What is still open at the end of the string (a tag, a comment, or an element whose content is text,
|
|
383
|
+
* like `<textarea>`) becomes text: on the server (SSR), the rest of the page follows the translation,
|
|
384
|
+
* and it would be read as a part of what is open
|
|
385
|
+
*
|
|
386
|
+
* @param html - The translated HTML
|
|
387
|
+
* @returns The sanitized HTML
|
|
388
|
+
*/
|
|
296
389
|
function sanitizeTranslatedHtml(html) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
390
|
+
const neutralized = {};
|
|
391
|
+
let result = '';
|
|
392
|
+
let index = 0;
|
|
393
|
+
let lessThan;
|
|
394
|
+
while ((lessThan = html.indexOf('<', index)) !== -1) {
|
|
395
|
+
result += html.slice(index, lessThan);
|
|
396
|
+
index = lessThan + 1;
|
|
397
|
+
const read = readTag(html, lessThan, neutralized);
|
|
398
|
+
if (read) {
|
|
399
|
+
const [tag, tagName, end] = read;
|
|
400
|
+
if (end === -1) {
|
|
401
|
+
neutralized.unclosed = true;
|
|
402
|
+
result += escapeLessThan(html.slice(lessThan));
|
|
403
|
+
index = html.length;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
index = end;
|
|
407
|
+
if (tag[1] === '/') {
|
|
408
|
+
result += tag;
|
|
409
|
+
}
|
|
410
|
+
else if (dangerousElementPattern.test(tagName)) {
|
|
411
|
+
// the start tag becomes text
|
|
412
|
+
neutralized.element = true;
|
|
413
|
+
result += escapeLessThan(tag);
|
|
414
|
+
}
|
|
415
|
+
else if (textContentElementPattern.test(tagName)) {
|
|
416
|
+
const contentEnd = findTextContentEnd(html, end, tagName);
|
|
417
|
+
if (contentEnd === -1) {
|
|
418
|
+
// the start tag becomes text, and the content is read as HTML, as browsers do then
|
|
419
|
+
neutralized.unclosed = true;
|
|
420
|
+
result += escapeLessThan(tag);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
result += tag + escapeLessThan(html.slice(end, contentEnd));
|
|
424
|
+
index = contentEnd;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
result += tag;
|
|
429
|
+
}
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
commentPattern.lastIndex = lessThan;
|
|
433
|
+
if (commentPattern.test(html)) {
|
|
434
|
+
result += html.slice(lessThan, commentPattern.lastIndex);
|
|
435
|
+
index = commentPattern.lastIndex;
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (html.startsWith('<!--', lessThan)) {
|
|
439
|
+
neutralized.unclosed = true;
|
|
440
|
+
}
|
|
441
|
+
// `<!DOCTYPE`, `<![CDATA[`, `<?`, `</` without a tag name, `<` at the end and any other `<` become text
|
|
442
|
+
result += '<';
|
|
443
|
+
}
|
|
444
|
+
result += html.slice(index);
|
|
445
|
+
{
|
|
446
|
+
if (neutralized.eventHandler) {
|
|
305
447
|
warn('Potentially dangerous event handlers detected in translation. ' +
|
|
306
448
|
'Consider removing onclick, onerror, etc. from your translation messages.');
|
|
307
449
|
}
|
|
308
|
-
|
|
309
|
-
html = html.replace(eventHandlerAttributePattern, '$1on$2');
|
|
310
|
-
}
|
|
311
|
-
// Detect and neutralize `srcdoc` attributes
|
|
312
|
-
if (srcdocPattern.test(html)) {
|
|
313
|
-
{
|
|
450
|
+
if (neutralized.srcdoc) {
|
|
314
451
|
warn('Potentially dangerous srcdoc attribute detected in translation. ' +
|
|
315
452
|
'Consider removing srcdoc from your translation messages.');
|
|
316
453
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
// Detect and neutralize `<base>`, `<animate>`, `<set>` and `<script>` elements
|
|
321
|
-
if (dangerousElementPattern.test(html)) {
|
|
322
|
-
{
|
|
323
|
-
warn('Potentially dangerous element (<base>, <animate>, <set> or <script>) ' +
|
|
454
|
+
if (neutralized.element) {
|
|
455
|
+
warn('Potentially dangerous element (<base>, <animate>, <set>, <script> or <plaintext>) ' +
|
|
324
456
|
'detected in translation. Consider removing it from your translation messages.');
|
|
325
457
|
}
|
|
326
|
-
|
|
327
|
-
|
|
458
|
+
if (neutralized.unclosed) {
|
|
459
|
+
warn('Unclosed tag, comment or element (such as <textarea>) detected in translation. ' +
|
|
460
|
+
'Consider closing it in your translation messages.');
|
|
461
|
+
}
|
|
328
462
|
}
|
|
329
|
-
|
|
330
|
-
html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
|
|
331
|
-
return html;
|
|
463
|
+
return result;
|
|
332
464
|
}
|
|
333
465
|
|
|
334
466
|
/**
|
|
@@ -2707,7 +2839,7 @@ function getWarnMessage$1(code, ...args) {
|
|
|
2707
2839
|
* Intlify core-base version
|
|
2708
2840
|
* @internal
|
|
2709
2841
|
*/
|
|
2710
|
-
const VERSION$1 = '11.4.
|
|
2842
|
+
const VERSION$1 = '11.4.19';
|
|
2711
2843
|
const NOT_REOSLVED = -1;
|
|
2712
2844
|
const DEFAULT_LOCALE = 'en-US';
|
|
2713
2845
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -3831,7 +3963,7 @@ function getMessageContextOptions(context, locale, message, options) {
|
|
|
3831
3963
|
*
|
|
3832
3964
|
* @VueI18nGeneral
|
|
3833
3965
|
*/
|
|
3834
|
-
const VERSION = '11.4.
|
|
3966
|
+
const VERSION = '11.4.19';
|
|
3835
3967
|
/**
|
|
3836
3968
|
* This is only called development env
|
|
3837
3969
|
* istanbul-ignore-next
|