From c97c1b6899eb94bcecb06509b380ab73ec183e24 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 21 May 2015 11:23:44 +0200 Subject: [PATCH] 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: a"b Is actually serialized back into the exact same instead of being serialized into: a"b --- lib/oga/xml/entities.rb | 2 -- spec/oga/xml/entities_spec.rb | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/oga/xml/entities.rb b/lib/oga/xml/entities.rb index 66a5615..eaea9d6 100644 --- a/lib/oga/xml/entities.rb +++ b/lib/oga/xml/entities.rb @@ -28,8 +28,6 @@ module Oga # ENCODE_MAPPING = { '&' => '&', - '"' => '"', - "'" => ''', '>' => '>', '<' => '<', } diff --git a/spec/oga/xml/entities_spec.rb b/spec/oga/xml/entities_spec.rb index 11161a1..f3bdb39 100644 --- a/spec/oga/xml/entities_spec.rb +++ b/spec/oga/xml/entities_spec.rb @@ -80,12 +80,12 @@ describe Oga::XML::Entities do described_class.encode('&').should == '&' end - it 'encodes " as "' do - described_class.encode('"').should == '"' + it 'does not encode double quotes' do + described_class.encode('"').should == '"' end - it "encodes ' as '" do - described_class.encode("'").should == ''' + it 'does not encode single quotes' do + described_class.encode("'").should == "'" end it 'encodes < as <' do