Handle lexing of input such as just "</".

Previously this would cause the lexer to go in an infinite loop in the "text"
state machine.

This fixes #37.
This commit is contained in:
Yorick Peterse 2014-09-15 17:20:06 +02:00
parent b06eadc812
commit ad2e040f05
2 changed files with 20 additions and 0 deletions

View File

@ -292,6 +292,14 @@
allowed_text = any* -- terminate_text;
text := |*
# Input such as just "</" or "<?". This rule takes precedence over the
# rules below, but only if those don't match.
terminate_text => {
callback("on_text", data, encoding, ts, te);
fnext main;
};
# Text followed by a special tag, such as "foo<!--"
allowed_text @{ mark = p; } terminate_text => {
callback("on_text", data, encoding, ts, mark);

View File

@ -21,5 +21,17 @@ describe Oga::XML::Lexer do
example 'lex a > as regular text' do
lex('>').should == [[:T_TEXT, '>', 1]]
end
example 'lex </ as regular text' do
lex('</').should == [[:T_TEXT, '</', 1]]
end
example 'lex <! as regular text' do
lex('<!').should == [[:T_TEXT, '<!', 1]]
end
example 'lex <? as regular text' do
lex('<?').should == [[:T_TEXT, '<?', 1]]
end
end
end