Ignore nested element start tags

This ensures that Oga is able to tokenize input such as the following:

    <script<script>foo</script>

Oga will now treat this as:

    <script>foo</script>

This is based on libxml behaviour, which seems to differ a bit from
Chromium which treats the node as a text node. This however would
require complex look-ahead logic (as far as I can tell) that I really
don't want to implement in Oga.

Fixes #186
This commit is contained in:
Yorick Peterse committed 2017-12-28 16:12:20 +01:00
1 parent 1e002de527
commit f574197ea6
2 files changed
+20

No files matched your search

+17
View File
@@ -344,4 +344,21 @@ describe Oga::XML::Lexer do
[:T_ELEM_END, nil, 1]
])
end
it 'lexes an element with a nested opening tag' do
expect(lex('<script<script>foo</script>')).to eq([
[:T_ELEM_NAME, 'script', 1],
[:T_TEXT, 'foo', 1],
[:T_ELEM_END, nil, 1]
])
end
it 'lexes an element with a nested opening tag followed by an attribute' do
expect(lex('<script<script foo>foo</script>')).to eq([
[:T_ELEM_NAME, 'script', 1],
[:T_ATTR, 'foo', 1],
[:T_TEXT, 'foo', 1],
[:T_ELEM_END, nil, 1]
])
end
end