logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: e0ef7f9d79ce0bd8307e6bf77a4dd77d83214809
parent: 127bfda521d97fd173acf3c4fdcedcb065f7eefb
Author: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Date:   Wed, 27 Dec 2017 11:29:49 +0900

Fix XML oEmbed support discovery (#6104)


Diffstat:

Mapp/lib/provider_discovery.rb2+-
Mspec/fixtures/requests/oembed_json_xml.html8+++++++-
Mspec/fixtures/requests/oembed_xml.html8+++++++-
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/app/lib/provider_discovery.rb b/app/lib/provider_discovery.rb @@ -29,7 +29,7 @@ class ProviderDiscovery < OEmbed::ProviderDiscovery end if format.nil? || format == :xml - provider_endpoint ||= html.at_xpath('//link[@type="application/xml+oembed"]')&.attribute('href')&.value + provider_endpoint ||= html.at_xpath('//link[@type="text/xml+oembed"]')&.attribute('href')&.value format ||= :xml if provider_endpoint end diff --git a/spec/fixtures/requests/oembed_json_xml.html b/spec/fixtures/requests/oembed_json_xml.html @@ -1,8 +1,14 @@ <!DOCTYPE html> <html> <head> + <!-- + oEmbed + https://oembed.com/ + > The type attribute must contain either application/json+oembed for JSON + > responses, or text/xml+oembed for XML. + --> <link href='https://host/provider.json' rel='alternate' type='application/json+oembed'> - <link href='https://host/provider.xml' rel='alternate' type='application/xml+oembed'> + <link href='https://host/provider.xml' rel='alternate' type='text/xml+oembed'> </head> <body></body> </html> diff --git a/spec/fixtures/requests/oembed_xml.html b/spec/fixtures/requests/oembed_xml.html @@ -1,7 +1,13 @@ <!DOCTYPE html> <html> <head> - <link href='https://host/provider.xml' rel='alternate' type='application/xml+oembed'> + <!-- + oEmbed + https://oembed.com/ + > The type attribute must contain either application/json+oembed for JSON + > responses, or text/xml+oembed for XML. + --> + <link href='https://host/provider.xml' rel='alternate' type='text/xml+oembed'> </head> <body></body> </html>