A platform for community discussion. Free, open, simple.
FIX: Replace Vimeo iframes with a link in emails (#11443)
Bianca Nenciu8ff9cdf390a4
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex d9bc62ad192..5a109024085 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -401,7 +401,7 @@ module PrettyTextvimeo_id = iframe['src'].split('/').lastvimeo_url = "https://vimeo.com/#{vimeo_id}"end- iframe.replace "<p><a href='#{vimeo_url}'>#{vimeo_url}</a></p>"+ iframe.replace Nokogiri::HTML5.fragment("<p><a href='#{vimeo_url}'>#{vimeo_url}</a></p>")endenddiff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rbindex cb574b096c1..274b00c62ce 100644--- a/spec/components/pretty_text_spec.rb+++ b/spec/components/pretty_text_spec.rb@@ -900,6 +900,23 @@ describe PrettyText doexpect(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 <iframe> to <a>" do+ html = <<~HTML+ <p>This is a Vimeo link:</p>+ <iframe width="640" height="360" src="https://player.vimeo.com/video/1" data-original-href="https://vimeo.com/1" frameborder="0" allowfullscreen="" seamless="seamless" sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation"></iframe>+ HTML++ md = PrettyText.format_for_email(html, post)++ expect(md).not_to include('<iframe')+ expect(md).to match_html(<<~HTML)+ <p>This is a Vimeo link:</p>+ <p><a href="https://vimeo.com/1">https://vimeo.com/1</a></p>+ HTML+ end+ end+describe "#strip_secure_media" dobefore dosetup_s3