FIX: prefer data-original-href attribute to get iframe URL
This commit is contained in:
parent
c811e59898
commit
bd1db1860a
|
@ -150,7 +150,7 @@ module Email
|
|||
next
|
||||
end
|
||||
|
||||
src_uri = URI(i['src'])
|
||||
src_uri = i["data-original-href"].present? ? URI(i["data-original-href"]) : URI(i['src'])
|
||||
# If an iframe is protocol relative, use SSL when displaying it
|
||||
display_src = "#{src_uri.scheme || 'https'}://#{src_uri.host}#{src_uri.path}#{src_uri.query.nil? ? '' : '?' + src_uri.query}#{src_uri.fragment.nil? ? '' : '#' + src_uri.fragment}"
|
||||
i.replace "<p><a href='#{src_uri.to_s}'>#{CGI.escapeHTML(display_src)}</a><p>"
|
||||
|
|
|
@ -106,6 +106,15 @@ describe Email::Styles do
|
|||
expect(frag.at('iframe')).to be_blank
|
||||
expect(frag.at('a')).to be_blank
|
||||
end
|
||||
|
||||
it "prefers data-original-href attribute to get iframe link" do
|
||||
original_url = "https://vimeo.com/329875646"
|
||||
iframe_url = "https://player.vimeo.com/video/329875646"
|
||||
frag = html_fragment("<iframe src=\"#{iframe_url}\" data-original-href=\"#{original_url}\"></iframe>")
|
||||
expect(frag.at('iframe')).to be_blank
|
||||
expect(frag.at('a')).to be_present
|
||||
expect(frag.at('a')['href']).to eq(original_url)
|
||||
end
|
||||
end
|
||||
|
||||
context "rewriting protocol relative URLs to the forum" do
|
||||
|
|
Loading…
Reference in New Issue