From 8ff9cdf390a4cc0587a8a3269fb7db9f8ee279a1 Mon Sep 17 00:00:00 2001
From: Bianca Nenciu
Date: Wed, 9 Dec 2020 14:58:36 +0200
Subject: [PATCH] FIX: Replace Vimeo iframes with a link in emails (#11443)
This was implemented before, but it was not tested and broke at some
point (probably Nokogiri update).
---
lib/pretty_text.rb | 2 +-
spec/components/pretty_text_spec.rb | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index d9bc62ad192..5a109024085 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -401,7 +401,7 @@ module PrettyText
vimeo_id = iframe['src'].split('/').last
vimeo_url = "https://vimeo.com/#{vimeo_id}"
end
- iframe.replace "#{vimeo_url}
"
+ iframe.replace Nokogiri::HTML5.fragment("#{vimeo_url}
")
end
end
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index cb574b096c1..274b00c62ce 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -900,6 +900,23 @@ describe PrettyText do
expect(PrettyText.format_for_email(html, post)).to match(Regexp.escape("https://vimeo.com/329875646/%3E%20%3Cscript%3Ealert(1)%3C/script%3E"))
end
+ describe "#convert_vimeo_iframes" do
+ it "converts
+ https://vimeo.com/1
+ HTML
+ end
+ end
+
describe "#strip_secure_media" do
before do
setup_s3