Skip to content

Commit

Permalink
fix(ssr): should also escape static text content
Browse files Browse the repository at this point in the history
fix #6345
  • Loading branch information
yyx990803 committed Aug 29, 2017
1 parent f4ee63c commit 172dbf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/optimizing-compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
applyModelTransform
} from './modules'

import { escape } from 'web/server/util'
import { optimizability } from './optimizer'

import type { CodegenResult } from 'compiler/codegen/index'

export type StringSegment = {
Expand Down Expand Up @@ -222,7 +222,7 @@ function nodesToSegments (
} else if (c.type === 2) {
segments.push({ type: INTERPOLATION, value: c.expression })
} else if (c.type === 3) {
segments.push({ type: RAW, value: c.text })
segments.push({ type: RAW, value: escape(c.text) })
}
}
return segments
Expand Down
9 changes: 9 additions & 0 deletions test/ssr/ssr-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,15 @@ describe('SSR: renderToString', () => {
done()
})
})

it('should escape static strings', done => {
renderVmWithOptions(({
template: `<div>&lt;foo&gt;</div>`
}), res => {
expect(res).toBe(`<div data-server-rendered="true">&lt;foo&gt;</div>`)
done()
})
})
})

function renderVmWithOptions (options, cb) {
Expand Down

0 comments on commit 172dbf9

Please sign in to comment.