]> cat aescling's git repositories - mastodon.git/commitdiff
Fix XML oEmbed support discovery (#6104)
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Wed, 27 Dec 2017 02:29:49 +0000 (11:29 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 27 Dec 2017 02:29:49 +0000 (03:29 +0100)
app/lib/provider_discovery.rb
spec/fixtures/requests/oembed_json_xml.html
spec/fixtures/requests/oembed_xml.html

index 04ba381010e3e6bab8b883293d77bf781d5ab91c..5732e4fcb43943cd0ca89780272987ae5885d172 100644 (file)
@@ -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
 
index b5fc9bed09c6e5243e82cce7b167e280bf6eb547..8afd8e9972fc99b17ff5031bc4dfc06d05ad8506 100644 (file)
@@ -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>
index 5d7633e71325503b206b58e822167535f2907cf1..bdfcca17078b683f0ee32b5a46b907cdb6fd58ce 100644 (file)
@@ -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>