Skip to content

Commit 7ce035d

Browse files
committed
template parser: improve HTML entity regex (fix vuejs#1330)
1 parent e6f5a70 commit 7ce035d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/parsers/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function isRealTemplate (node) {
7070
}
7171

7272
var tagRE = /<([\w:]+)/
73-
var entityRE = /&\w+;/
73+
var entityRE = /&\w+;|&#\d+;|&#x[\dA-F]+;/
7474

7575
/**
7676
* Convert a string template to a DocumentFragment.

test/unit/specs/parsers/template_spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ if (_.inBrowser) {
4242
expect(res instanceof DocumentFragment).toBeTruthy()
4343
expect(res.childNodes.length).toBe(1)
4444
expect(res.firstChild.nodeValue).toBe('hi<hi')
45+
// #1330
46+
res = parse('hello &#x2F; hello')
47+
expect(res instanceof DocumentFragment).toBeTruthy()
48+
expect(res.childNodes.length).toBe(1)
49+
expect(res.firstChild.nodeValue).toBe('hello / hello')
4550
})
4651

4752
it('should parse textContent if argument is a script node', function () {

0 commit comments

Comments
 (0)