FIX: Allow html tags in oembed html method

FIX: Allow html tags in oembed html method

diff --git a/lib/onebox/oembed.rb b/lib/onebox/oembed.rb
index d9288d2..0ee6488 100644
--- a/lib/onebox/oembed.rb
+++ b/lib/onebox/oembed.rb
@@ -8,5 +8,8 @@ module Onebox
       data.delete(:html) if data[:html] && data[:html]["wp-embedded-content"]
     end
 
+    def html
+      get(:html, nil, false)
+    end
   end
 end
diff --git a/lib/onebox/open_graph.rb b/lib/onebox/open_graph.rb
index 06b1ad3..39cfd67 100644
--- a/lib/onebox/open_graph.rb
+++ b/lib/onebox/open_graph.rb
@@ -36,14 +36,16 @@ module Onebox
       end
     end
 
-    def get(attr, length = nil)
+    def get(attr, length = nil, sanitize = true)
       return nil if Onebox::Helpers::blank?(data)
 
       value = data[attr]
 
       return nil if Onebox::Helpers::blank?(value)
 
-      value = Sanitize.fragment(html_entities.decode(value)).strip
+      value = html_entities.decode(value)
+      value = Sanitize.fragment(value) if sanitize
+      value.strip!
       value = Onebox::Helpers.truncate(value, length) unless length.nil?
 
       value
diff --git a/spec/lib/onebox/oembed_spec.rb b/spec/lib/onebox/oembed_spec.rb
new file mode 100644
index 0000000..616b842
--- /dev/null
+++ b/spec/lib/onebox/oembed_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+require "onebox/oembed"
+
+describe Onebox::Oembed do
+
+  it "excludes html tags" do
+    json = '{"text": "<iframe src=\'https://ifram.es/foo/bar\'></iframe>"}'
+    oembed = described_class.new(json)
+    expect(oembed.text).to be_nil
+  end
+
+  it "includes html tags" do
+    json = '{"html": "<iframe src=\'https://ifram.es/foo/bar\'></iframe>"}'
+    oembed = described_class.new(json)
+    expect(oembed.html).to eq("<iframe src='https://ifram.es/foo/bar'></iframe>")
+  end
+end

GitHub sha: ca86c3b1