Decoding of zero padded XML entities

This would previously fail due to the lack of an explicit base to use
for Integer().
This commit is contained in:
Yorick Peterse 2015-04-20 00:13:15 +02:00
parent 13e2c3d82f
commit 853d804f34
2 changed files with 5 additions and 1 deletions

View File

@ -72,7 +72,7 @@ module Oga
if input.include?(AMPERSAND) if input.include?(AMPERSAND)
input = input.gsub(CODEPOINT_ENTITY) do |match| 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
end end

View File

@ -69,6 +69,10 @@ describe Oga::XML::Entities do
it 'decodes &#x3C; into <' do it 'decodes &#x3C; into <' do
described_class.decode('&#x3C;').should == '<' described_class.decode('&#x3C;').should == '<'
end end
it 'decodes numeric entities starting with a 0' do
described_class.decode('&#038;').should == '&'
end
end end
describe 'encode' do describe 'encode' do