about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2017-07-05 21:54:21 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-07-05 14:54:21 +0200
commit5e6acf960183aea9440ce0d9e28c86f043e88c54 (patch)
tree145946d82afd2ee204e3bfc9e7dcb5d5069eb45f /app/services
parentb52a5e6bd60be3f9548cf59eb313b1e6c2f5920e (diff)
Fix Nokogiri::HTML at FetchLinkCardService (#4072)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fetch_link_card_service.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 4ce221267..8ddaa2bf4 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+require 'nkf'
 
 class FetchLinkCardService < BaseService
   include HttpHelper
@@ -84,7 +85,8 @@ class FetchLinkCardService < BaseService
 
     return if response.code != 200 || response.mime_type != 'text/html'
 
-    page = Nokogiri::HTML(response.to_s)
+    html = response.to_s
+    page = Nokogiri::HTML(html, nil, NKF.guess(html).to_s)
 
     card.type             = :link
     card.title            = meta_property(page, 'og:title') || page.at_xpath('//title')&.content