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

Only match title, style, script lowercase variants #81

Merged
merged 2 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/evented-tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class EventedTokenizer {
}

private isIgnoredEndTag(): boolean {
let tag = this.tagNameBuffer.toLowerCase();
let tag = this.tagNameBuffer;

return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
(tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
Expand Down Expand Up @@ -146,7 +146,7 @@ export default class EventedTokenizer {

data() {
let char = this.peek();
let tag = this.tagNameBuffer.toLowerCase();
let tag = this.tagNameBuffer;

if (char === '<' && !this.isIgnoredEndTag()) {
this.delegate.finishData();
Expand Down
6 changes: 6 additions & 0 deletions tests/tokenizer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ QUnit.test('The title element content is always text', function(assert) {
assert.deepEqual(tokens, [startTag('title'), chars('"hey <b>there</b><!-- comment -->'), endTag('title')]);
});

// https://github.com/emberjs/ember.js/issues/18530
QUnit.test('Title element content is not text', function(assert) {
let tokens = tokenize("<Title><!-- hello --></Title>");
assert.deepEqual(tokens, [startTag('Title'), comment(' hello '), endTag('Title')]);
});

// https://html.spec.whatwg.org/multipage/semantics.html#the-style-element
QUnit.test('The style element content is always text', function(assert) {
let tokens = tokenize("<style>&quot;hey <b>there</b><!-- comment --></style>");
Expand Down