diff --git a/lib/oga/xml/entities.rb b/lib/oga/xml/entities.rb index 470036e..66a5615 100644 --- a/lib/oga/xml/entities.rb +++ b/lib/oga/xml/entities.rb @@ -72,7 +72,7 @@ module Oga if input.include?(AMPERSAND) input = input.gsub(CODEPOINT_ENTITY) do |match| - [$1 ? Integer($2, 16) : Integer($2)].pack('U') + [$1 ? Integer($2, 16) : Integer($2, 10)].pack('U*') end end diff --git a/spec/oga/xml/entities_spec.rb b/spec/oga/xml/entities_spec.rb index 68bf4d3..11161a1 100644 --- a/spec/oga/xml/entities_spec.rb +++ b/spec/oga/xml/entities_spec.rb @@ -69,6 +69,10 @@ describe Oga::XML::Entities do it 'decodes < into <' do described_class.decode('<').should == '<' end + + it 'decodes numeric entities starting with a 0' do + described_class.decode('&').should == '&' + end end describe 'encode' do