Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix HTML escaping and non-top-level <script> and <style> issues #1086

Merged
merged 7 commits into from
Jan 9, 2018
Prev Previous commit
Next Next commit
parse non-top-level <script> and <style> tags as one piece of Text
Conduitry committed Jan 8, 2018

Verified

This commit was signed with the committer’s verified signature.
ijjk JJ Kasper
commit 41744e25fc0ff302ec40c32eb74a0935ec11ea1b
9 changes: 8 additions & 1 deletion src/parse/state/tag.ts
Original file line number Diff line number Diff line change
@@ -213,6 +213,7 @@ export default function tag(parser: Parser) {
parser.eat('>', true);

if (selfClosing) {
// don't push self-closing elements onto the stack
element.end = parser.index;
} else if (name === 'textarea') {
// special case
@@ -223,8 +224,14 @@ export default function tag(parser: Parser) {
);
parser.read(/<\/textarea>/);
element.end = parser.index;
} else if (name === 'script' || name === 'style') {
// special case
const start = parser.index;
const data = parser.readUntil(new RegExp(`</${name}>`));
const end = parser.index;
element.children.push({ start, end, type: 'Text', data });
parser.eat(`</${name}>`, true);
} else {
// don't push self-closing elements onto the stack
parser.stack.push(element);
}
}