diff --git a/ext/ragel/base_lexer.rl b/ext/ragel/base_lexer.rl index 21f75ad..4b7a4b1 100644 --- a/ext/ragel/base_lexer.rl +++ b/ext/ragel/base_lexer.rl @@ -116,8 +116,8 @@ dquote = '"'; squote = "'"; - string_dquote = (dquote ^dquote+ dquote); - string_squote = (squote ^squote+ squote); + string_dquote = (dquote ^dquote* dquote); + string_squote = (squote ^squote* squote); string = string_dquote | string_squote; diff --git a/spec/oga/xml/lexer/elements_spec.rb b/spec/oga/xml/lexer/elements_spec.rb index 97054ab..3455e2b 100644 --- a/spec/oga/xml/lexer/elements_spec.rb +++ b/spec/oga/xml/lexer/elements_spec.rb @@ -53,6 +53,16 @@ describe Oga::XML::Lexer do ] end + example 'lex an element with an attribute with an empty value' do + lex('

').should == [ + [:T_ELEM_START, nil, 1], + [:T_ELEM_NAME, 'p', 1], + [:T_ATTR, 'foo', 1], + [:T_STRING, '', 1], + [:T_ELEM_END, nil, 1] + ] + end + example 'lex a paragraph element with attributes' do lex('

Hello

').should == [ [:T_ELEM_START, nil, 1], diff --git a/spec/oga/xml/parser/elements_spec.rb b/spec/oga/xml/parser/elements_spec.rb index 4488594..afe317f 100644 --- a/spec/oga/xml/parser/elements_spec.rb +++ b/spec/oga/xml/parser/elements_spec.rb @@ -55,6 +55,34 @@ describe Oga::XML::Parser do end end + context 'elements with attributes without values' do + before :all do + @element = parse('').children[0] + end + + example 'return an Element instance' do + @element.is_a?(Oga::XML::Element).should == true + end + + example 'set the bar attribute' do + @element.attribute('bar').value.should be_nil + end + end + + context 'elements with attributes with empty values' do + before :all do + @element = parse('').children[0] + end + + example 'return an Element instance' do + @element.is_a?(Oga::XML::Element).should == true + end + + example 'set the bar attribute' do + @element.attribute('bar').value.should == '' + end + end + context 'elements with namespaced attributes' do before :all do @element = parse('').children[0]