Merge pull request #67 from krasnoukhov/xml-entities
Add missing entities to the decode/encode lists
This commit is contained in:
commit
a10fe855d7
|
@ -11,8 +11,15 @@ module Oga
|
|||
#
|
||||
DECODE_MAPPING = {
|
||||
'<' => '<',
|
||||
'<' => '<',
|
||||
'>' => '>',
|
||||
'&' => '&'
|
||||
'>' => '>',
|
||||
''' => "'",
|
||||
''' => "'",
|
||||
'"' => '"',
|
||||
'"' => '"',
|
||||
'&' => '&',
|
||||
'&' => '&',
|
||||
}
|
||||
|
||||
##
|
||||
|
@ -22,8 +29,10 @@ module Oga
|
|||
#
|
||||
ENCODE_MAPPING = {
|
||||
'&' => '&',
|
||||
'"' => '"',
|
||||
"'" => ''',
|
||||
'>' => '>',
|
||||
'<' => '<'
|
||||
'<' => '<',
|
||||
}
|
||||
|
||||
##
|
||||
|
|
|
@ -2,10 +2,6 @@ require 'spec_helper'
|
|||
|
||||
describe Oga::XML::Entities do
|
||||
context 'decode' do
|
||||
example 'decode & into &' do
|
||||
described_class.decode('&').should == '&'
|
||||
end
|
||||
|
||||
example 'decode < into <' do
|
||||
described_class.decode('<').should == '<'
|
||||
end
|
||||
|
@ -14,6 +10,46 @@ describe Oga::XML::Entities do
|
|||
described_class.decode('>').should == '>'
|
||||
end
|
||||
|
||||
example "decode ' into '" do
|
||||
described_class.decode(''').should == "'"
|
||||
end
|
||||
|
||||
example 'decode " into "' do
|
||||
described_class.decode('"').should == '"'
|
||||
end
|
||||
|
||||
example 'decode & into &' do
|
||||
described_class.decode('&').should == '&'
|
||||
end
|
||||
|
||||
example 'decode < into <' do
|
||||
described_class.decode('<').should == '<'
|
||||
end
|
||||
|
||||
example 'decode > into >' do
|
||||
described_class.decode('>').should == '>'
|
||||
end
|
||||
|
||||
example "decode ' into '" do
|
||||
described_class.decode(''').should == "'"
|
||||
end
|
||||
|
||||
example 'decode " into "' do
|
||||
described_class.decode('"').should == '"'
|
||||
end
|
||||
|
||||
example 'decode & into &' do
|
||||
described_class.decode('&').should == '&'
|
||||
end
|
||||
|
||||
example 'decode &#60; into <' do
|
||||
described_class.decode('&#60;').should == '<'
|
||||
end
|
||||
|
||||
example 'decode &#38; into &' do
|
||||
described_class.decode('&#38;').should == '&'
|
||||
end
|
||||
|
||||
example 'decode &gt; into >' do
|
||||
described_class.decode('&gt;').should == '>'
|
||||
end
|
||||
|
@ -36,6 +72,14 @@ describe Oga::XML::Entities do
|
|||
described_class.encode('&').should == '&'
|
||||
end
|
||||
|
||||
example 'encode " as "' do
|
||||
described_class.encode('"').should == '"'
|
||||
end
|
||||
|
||||
example "encode ' as '" do
|
||||
described_class.encode("'").should == '''
|
||||
end
|
||||
|
||||
example 'encode < as <' do
|
||||
described_class.encode('<').should == '<'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue