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:
parent
b06eadc812
commit
ad2e040f05
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue