Skip to content

Commit

Permalink
fix: allow codebase to be inlined directly in HTML (vuejs#7314)
Browse files Browse the repository at this point in the history
escape - to avoid regex being parsed as HTML comment when entire codebase is inlined.
fix vuejs#7298
  • Loading branch information
mengjian-github authored and aJean committed Aug 19, 2020
1 parent d9e1097 commit cf8ece9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compiler/parser/html-parser.js
Expand Up @@ -22,7 +22,8 @@ const startTagOpen = new RegExp(`^<${qnameCapture}`)
const startTagClose = /^\s*(\/?)>/
const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`)
const doctype = /^<!DOCTYPE [^>]+>/i
const comment = /^<!--/
// #7298: escape - to avoid being pased as HTML comment when inlined in page
const comment = /^<!\--/
const conditionalComment = /^<!\[/

let IS_REGEX_CAPTURING_BROKEN = false
Expand Down Expand Up @@ -152,7 +153,7 @@ export function parseHTML (html, options) {
endTagLength = endTag.length
if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
text = text
.replace(/<!--([\s\S]*?)-->/g, '$1')
.replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
.replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1')
}
if (shouldIgnoreFirstNewline(stackedTag, text)) {
Expand Down

0 comments on commit cf8ece9

Please sign in to comment.