Skip to content

Commit 784c06e

Browse files
authored
Merge pull request #2158 from didi/fix-rich-text-encode
fix: web 环境 rich-text 组件 nodes 属性包含 < 字符导致页面崩溃
2 parents 2ef0000 + 64f1fc9 commit 784c06e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • packages/webpack-plugin/lib/runtime/components/web

packages/webpack-plugin/lib/runtime/components/web/filterTag.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ function parseHTML (html, options) {
8888
match.end = index
8989
handleStartTag(match)
9090
}
91+
continue
92+
}
93+
94+
// If we reach here, the `<` at position 0 does not start a valid tag/comment/end tag
95+
// Treat it as plain text to avoid infinite loop on stray '<'
96+
if (options.chars) {
97+
options.chars('<')
9198
}
99+
advance(1)
100+
continue
92101
}
93102
let text, rest, next
94103
if (textEnd >= 0) {

0 commit comments

Comments
 (0)