Do not encode single/double quotes as entities

By encoding single/double quotes we can potentially break input, so lets
stop doing this. This now ensures that this:

    <foo>a"b</foo>

Is actually serialized back into the exact same instead of being
serialized into:

    <foo>a&quot;b</foo>
This commit is contained in:
Yorick Peterse 2015-05-21 11:23:44 +02:00
parent 098cd51ab7
commit c97c1b6899
2 changed files with 4 additions and 6 deletions

View File

@ -28,8 +28,6 @@ module Oga
#
ENCODE_MAPPING = {
'&' => '&amp;',
'"' => '&quot;',
"'" => '&apos;',
'>' => '&gt;',
'<' => '&lt;',
}

View File

@ -80,12 +80,12 @@ describe Oga::XML::Entities do
described_class.encode('&').should == '&amp;'
end
it 'encodes " as &quot;' do
described_class.encode('"').should == '&quot;'
it 'does not encode double quotes' do
described_class.encode('"').should == '"'
end
it "encodes ' as &apos;" do
described_class.encode("'").should == '&apos;'
it 'does not encode single quotes' do
described_class.encode("'").should == "'"
end
it 'encodes < as &lt;' do