Skip to content

Commit 1caa697

Browse files
author
Eric Lakatos
committed
fix: serialize-javascript vulnerability by updating package (#10910)
1 parent 068afee commit 1caa697

File tree

6 files changed

+63
-27
lines changed

6 files changed

+63
-27
lines changed

Diff for: dist/vue.runtime.common.dev.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
19561956
isUsingMicroTask = true;
19571957
} else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
19581958
// Fallback to setImmediate.
1959-
// Techinically it leverages the (macro) task queue,
1959+
// Technically it leverages the (macro) task queue,
19601960
// but it is still a better choice than setTimeout.
19611961
timerFunc = function () {
19621962
setImmediate(flushCallbacks);
@@ -2022,7 +2022,7 @@ var initProxy;
20222022
warn(
20232023
"Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
20242024
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
2025-
'prevent conflicts with Vue internals' +
2025+
'prevent conflicts with Vue internals. ' +
20262026
'See: https://vuejs.org/v2/api/#data',
20272027
target
20282028
);
@@ -2905,7 +2905,7 @@ function bindDynamicKeys (baseObj, values) {
29052905
if (typeof key === 'string' && key) {
29062906
baseObj[values[i]] = values[i + 1];
29072907
} else if (key !== '' && key !== null) {
2908-
// null is a speical value for explicitly removing a binding
2908+
// null is a special value for explicitly removing a binding
29092909
warn(
29102910
("Invalid value for dynamic directive argument (expected string or null): " + key),
29112911
this
@@ -3400,6 +3400,12 @@ function _createElement (
34003400
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
34013401
if (config.isReservedTag(tag)) {
34023402
// platform built-in elements
3403+
if (isDef(data) && isDef(data.nativeOn)) {
3404+
warn(
3405+
("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
3406+
context
3407+
);
3408+
}
34033409
vnode = new VNode(
34043410
config.parsePlatformTagName(tag), data, children,
34053411
undefined, undefined, context
@@ -3525,7 +3531,7 @@ function renderMixin (Vue) {
35253531
// render self
35263532
var vnode;
35273533
try {
3528-
// There's no need to maintain a stack becaues all render fns are called
3534+
// There's no need to maintain a stack because all render fns are called
35293535
// separately from one another. Nested component's render fns are called
35303536
// when parent component is patched.
35313537
currentRenderingInstance = vm;
@@ -6095,7 +6101,7 @@ function createPatchFunction (backend) {
60956101
}
60966102
}
60976103

6098-
function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
6104+
function removeVnodes (vnodes, startIdx, endIdx) {
60996105
for (; startIdx <= endIdx; ++startIdx) {
61006106
var ch = vnodes[startIdx];
61016107
if (isDef(ch)) {
@@ -6206,7 +6212,7 @@ function createPatchFunction (backend) {
62066212
refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
62076213
addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
62086214
} else if (newStartIdx > newEndIdx) {
6209-
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
6215+
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
62106216
}
62116217
}
62126218

@@ -6298,7 +6304,7 @@ function createPatchFunction (backend) {
62986304
if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
62996305
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
63006306
} else if (isDef(oldCh)) {
6301-
removeVnodes(elm, oldCh, 0, oldCh.length - 1);
6307+
removeVnodes(oldCh, 0, oldCh.length - 1);
63026308
} else if (isDef(oldVnode.text)) {
63036309
nodeOps.setTextContent(elm, '');
63046310
}
@@ -6527,7 +6533,7 @@ function createPatchFunction (backend) {
65276533

65286534
// destroy old node
65296535
if (isDef(parentElm)) {
6530-
removeVnodes(parentElm, [oldVnode], 0, 0);
6536+
removeVnodes([oldVnode], 0, 0);
65316537
} else if (isDef(oldVnode.tag)) {
65326538
invokeDestroyHook(oldVnode);
65336539
}

Diff for: dist/vue.runtime.common.prod.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"rollup-plugin-node-resolve": "^4.0.0",
134134
"rollup-plugin-replace": "^2.0.0",
135135
"selenium-server": "^2.53.1",
136-
"serialize-javascript": "^1.3.0",
136+
"serialize-javascript": "^2.1.0",
137137
"shelljs": "^0.8.1",
138138
"terser": "^3.10.2",
139139
"typescript": "^3.6.4",

Diff for: packages/vue-server-renderer/basic.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -3373,7 +3373,7 @@
33733373
var startTagClose = /^\s*(\/?)>/;
33743374
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
33753375
var doctype = /^<!DOCTYPE [^>]+>/i;
3376-
// #7298: escape - to avoid being pased as HTML comment when inlined in page
3376+
// #7298: escape - to avoid being passed as HTML comment when inlined in page
33773377
var comment = /^<!\--/;
33783378
var conditionalComment = /^<!\[/;
33793379

@@ -3806,7 +3806,7 @@
38063806
/* */
38073807

38083808
var onRE = /^@|^v-on:/;
3809-
var dirRE = /^v-|^@|^:/;
3809+
var dirRE = /^v-|^@|^:|^#/;
38103810
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
38113811
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
38123812
var stripParensRE = /^\(|\)$/g;
@@ -4430,7 +4430,7 @@
44304430
if (el.parent && !maybeComponent(el.parent)) {
44314431
warn$1(
44324432
"<template v-slot> can only appear at the root level inside " +
4433-
"the receiving the component",
4433+
"the receiving component",
44344434
el
44354435
);
44364436
}
@@ -5032,7 +5032,7 @@
50325032

50335033
/* */
50345034

5035-
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
5035+
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
50365036
var fnInvokeRE = /\([^)]*?\);*$/;
50375037
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
50385038

@@ -6272,6 +6272,8 @@
62726272
var range = node.rawAttrsMap[name];
62736273
if (name === 'v-for') {
62746274
checkFor(node, ("v-for=\"" + value + "\""), warn, range);
6275+
} else if (name === 'v-slot' || name[0] === '#') {
6276+
checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
62756277
} else if (onRE.test(name)) {
62766278
checkEvent(value, (name + "=\"" + value + "\""), warn, range);
62776279
} else {
@@ -6291,9 +6293,9 @@
62916293
}
62926294

62936295
function checkEvent (exp, text, warn, range) {
6294-
var stipped = exp.replace(stripStringRE, '');
6295-
var keywordMatch = stipped.match(unaryOperatorsRE);
6296-
if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
6296+
var stripped = exp.replace(stripStringRE, '');
6297+
var keywordMatch = stripped.match(unaryOperatorsRE);
6298+
if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
62976299
warn(
62986300
"avoid using JavaScript unary operator as property name: " +
62996301
"\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
@@ -6348,6 +6350,19 @@
63486350
}
63496351
}
63506352

6353+
function checkFunctionParameterExpression (exp, text, warn, range) {
6354+
try {
6355+
new Function(exp, '');
6356+
} catch (e) {
6357+
warn(
6358+
"invalid function parameter expression: " + (e.message) + " in\n\n" +
6359+
" " + exp + "\n\n" +
6360+
" Raw expression: " + (text.trim()) + "\n",
6361+
range
6362+
);
6363+
}
6364+
}
6365+
63516366
/* */
63526367

63536368
var range = 2;
@@ -7473,7 +7488,7 @@
74737488
if (typeof key === 'string' && key) {
74747489
baseObj[values[i]] = values[i + 1];
74757490
} else if (key !== '' && key !== null) {
7476-
// null is a speical value for explicitly removing a binding
7491+
// null is a special value for explicitly removing a binding
74777492
warn(
74787493
("Invalid value for dynamic directive argument (expected string or null): " + key),
74797494
this

Diff for: packages/vue-server-renderer/build.dev.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -3123,7 +3123,7 @@ var startTagOpen = new RegExp(("^<" + qnameCapture));
31233123
var startTagClose = /^\s*(\/?)>/;
31243124
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
31253125
var doctype = /^<!DOCTYPE [^>]+>/i;
3126-
// #7298: escape - to avoid being pased as HTML comment when inlined in page
3126+
// #7298: escape - to avoid being passed as HTML comment when inlined in page
31273127
var comment = /^<!\--/;
31283128
var conditionalComment = /^<!\[/;
31293129

@@ -3556,7 +3556,7 @@ function parseString (chr) {
35563556
/* */
35573557

35583558
var onRE = /^@|^v-on:/;
3559-
var dirRE = /^v-|^@|^:/;
3559+
var dirRE = /^v-|^@|^:|^#/;
35603560
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
35613561
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
35623562
var stripParensRE = /^\(|\)$/g;
@@ -4180,7 +4180,7 @@ function processSlotContent (el) {
41804180
if (el.parent && !maybeComponent(el.parent)) {
41814181
warn$1(
41824182
"<template v-slot> can only appear at the root level inside " +
4183-
"the receiving the component",
4183+
"the receiving component",
41844184
el
41854185
);
41864186
}
@@ -4782,7 +4782,7 @@ var baseOptions = {
47824782

47834783
/* */
47844784

4785-
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
4785+
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
47864786
var fnInvokeRE = /\([^)]*?\);*$/;
47874787
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
47884788

@@ -6022,6 +6022,8 @@ function checkNode (node, warn) {
60226022
var range = node.rawAttrsMap[name];
60236023
if (name === 'v-for') {
60246024
checkFor(node, ("v-for=\"" + value + "\""), warn, range);
6025+
} else if (name === 'v-slot' || name[0] === '#') {
6026+
checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
60256027
} else if (onRE.test(name)) {
60266028
checkEvent(value, (name + "=\"" + value + "\""), warn, range);
60276029
} else {
@@ -6041,9 +6043,9 @@ function checkNode (node, warn) {
60416043
}
60426044

60436045
function checkEvent (exp, text, warn, range) {
6044-
var stipped = exp.replace(stripStringRE, '');
6045-
var keywordMatch = stipped.match(unaryOperatorsRE);
6046-
if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
6046+
var stripped = exp.replace(stripStringRE, '');
6047+
var keywordMatch = stripped.match(unaryOperatorsRE);
6048+
if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
60476049
warn(
60486050
"avoid using JavaScript unary operator as property name: " +
60496051
"\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
@@ -6098,6 +6100,19 @@ function checkExpression (exp, text, warn, range) {
60986100
}
60996101
}
61006102

6103+
function checkFunctionParameterExpression (exp, text, warn, range) {
6104+
try {
6105+
new Function(exp, '');
6106+
} catch (e) {
6107+
warn(
6108+
"invalid function parameter expression: " + (e.message) + " in\n\n" +
6109+
" " + exp + "\n\n" +
6110+
" Raw expression: " + (text.trim()) + "\n",
6111+
range
6112+
);
6113+
}
6114+
}
6115+
61016116
/* */
61026117

61036118
var range = 2;
@@ -7223,7 +7238,7 @@ function bindDynamicKeys (baseObj, values) {
72237238
if (typeof key === 'string' && key) {
72247239
baseObj[values[i]] = values[i + 1];
72257240
} else if (key !== '' && key !== null) {
7226-
// null is a speical value for explicitly removing a binding
7241+
// null is a special value for explicitly removing a binding
72277242
warn(
72287243
("Invalid value for dynamic directive argument (expected string or null): " + key),
72297244
this

Diff for: packages/vue-server-renderer/build.prod.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)