Переглянути джерело

Treat meta[property] as a space-separated list (#10604)

The @property attribute in HTML is a space-separated list of values.
This change normalizes whitespace and finds the desired value in
the list instead of requiring an exact single-value match.

More details:
https://www.ctrl.blog/entry/rdfa-socialmedia-metadata.html
Daniel Aleksandersen 5 роки тому
батько
коміт
10bdd912d6
1 змінених файлів з 1 додано та 1 видалено
  1. 1 1
      app/services/fetch_link_card_service.rb

+ 1 - 1
app/services/fetch_link_card_service.rb

@@ -165,7 +165,7 @@ class FetchLinkCardService < BaseService
   end
 
   def meta_property(page, property)
-    page.at_xpath("//meta[@property=\"#{property}\"]")&.attribute('content')&.value || page.at_xpath("//meta[@name=\"#{property}\"]")&.attribute('content')&.value
+    page.at_xpath("//meta[contains(concat(' ', normalize-space(@property), ' '), ' #{property} ')]")&.attribute('content')&.value || page.at_xpath("//meta[@name=\"#{property}\"]")&.attribute('content')&.value
   end
 
   def lock_options