提交 ebfccde2 编写于 作者: G Guillaume Chau

fix(perf): limit string size, closes #652, closes #842

上级 7345d7ad
...@@ -62,6 +62,11 @@ const handler = { ...@@ -62,6 +62,11 @@ const handler = {
const proxy1 = new Proxy(sum, handler) const proxy1 = new Proxy(sum, handler)
let veryLongText = ''
for (let i = 0; i < 1000000; i++) {
veryLongText += `line${i}\n`
}
export default { export default {
components: { components: {
TestComponent: { TestComponent: {
...@@ -102,7 +107,8 @@ export default { ...@@ -102,7 +107,8 @@ export default {
sym: Symbol('test'), sym: Symbol('test'),
multiLineParameterFunction: function(a, multiLineParameterFunction: function(a,
b, b,
c) {} c) {},
veryLongText
} }
}, },
computed: { computed: {
......
...@@ -59,6 +59,8 @@ export const SPECIAL_TOKENS = { ...@@ -59,6 +59,8 @@ export const SPECIAL_TOKENS = {
'NaN': NAN 'NaN': NAN
} }
export const MAX_STRING_SIZE = 10000
export function specialTokenToString (value) { export function specialTokenToString (value) {
if (value === null) { if (value === null) {
return 'null' return 'null'
...@@ -149,6 +151,8 @@ function replacer (key) { ...@@ -149,6 +151,8 @@ function replacer (key) {
} }
} else if (Number.isNaN(val)) { } else if (Number.isNaN(val)) {
return NAN return NAN
} else if (typeof val === 'string' && val.length > MAX_STRING_SIZE) {
return val.substr(0, MAX_STRING_SIZE) + `... (${(val.length)} total length)`
} }
return sanitize(val) return sanitize(val)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册