diff --git a/src/platforms/web/server/modules/attrs.js b/src/platforms/web/server/modules/attrs.js index 544350bc..d1ebc76b 100644 --- a/src/platforms/web/server/modules/attrs.js +++ b/src/platforms/web/server/modules/attrs.js @@ -50,7 +50,7 @@ export function renderAttr (key: string, value: string): string { } else if (isEnumeratedAttr(key)) { return ` ${key}="${isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'}"` } else if (!isFalsyAttrValue(value)) { - return ` ${key}="${typeof value === 'string' ? cachedEscape(value) : value}"` + return ` ${key}="${cachedEscape(String(value))}"` } return '' } diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 3dfd3b44..24c20f92 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -821,6 +821,19 @@ describe('SSR: renderToString', () => { }) }) + it('should prevent script xss with v-bind object syntax + array value', done => { + renderVmWithOptions({ + data: { + test: ['">