about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorDaniel Aleksandersen <code@daniel.priv.no>2019-04-21 04:48:19 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-04-21 04:48:19 +0200
commit10bdd912d64a45d8b445f33cd10e498d8c071e56 (patch)
tree18954400721c98c4a4d29b05685f8b49cf968862 /app
parent01b1c377b1fea841b9823a3134e8f41ccc4b0f29 (diff)
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
Diffstat (limited to 'app')
-rw-r--r--app/services/fetch_link_card_service.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 7979c312e..494aaed75 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/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