Browse Source

Be more lenient with OEmbed detection and validation (#22533)

closed-social-glitch-2
Effy Elden 1 year ago
committed by GitHub
parent
commit
4dc9152b3e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      app/services/fetch_oembed_service.rb

+ 2
- 2
app/services/fetch_oembed_service.rb View File

@ -28,7 +28,7 @@ class FetchOEmbedService
page = Nokogiri::HTML(html)
if @format.nil? || @format == :json
@endpoint_url ||= page.at_xpath('//link[@type="application/json+oembed"]')&.attribute('href')&.value
@endpoint_url ||= page.at_xpath('//link[@type="application/json+oembed"]|//link[@type="text/json+oembed"]')&.attribute('href')&.value
@format ||= :json if @endpoint_url
end
@ -100,7 +100,7 @@ class FetchOEmbedService
end
def validate(oembed)
oembed if oembed[:version] == '1.0' && oembed[:type].present?
oembed if oembed[:version].to_s == '1.0' && oembed[:type].present?
end
def html

Loading…
Cancel
Save