about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-13 19:12:40 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-13 19:12:40 +0100
commit7ce46701646ddaee3f6a44a364a417c493cc4eb4 (patch)
treea2f8bd7a41f1f58ebbe0edeba3ede0d09a7ae7de /app/services
parent50d3083cbddf410e9024fb59559c46e9390a5662 (diff)
Force utf-8 encoding when processing XML
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fetch_remote_account_service.rb4
-rw-r--r--app/services/fetch_remote_status_service.rb4
-rw-r--r--app/services/process_feed_service.rb1
-rw-r--r--app/services/process_interaction_service.rb4
4 files changed, 10 insertions, 3 deletions
diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb
index 7a65236b6..7cbc9f6ec 100644
--- a/app/services/fetch_remote_account_service.rb
+++ b/app/services/fetch_remote_account_service.rb
@@ -9,7 +9,9 @@ class FetchRemoteAccountService < BaseService
   private
 
   def process_atom(url, body)
-    xml       = Nokogiri::XML(body)
+    xml = Nokogiri::XML(body)
+    xml.encoding = 'utf-8'
+
     url_parts = Addressable::URI.parse(url)
     username  = xml.at_xpath('//xmlns:author/xmlns:name').try(:content)
     domain    = url_parts.host
diff --git a/app/services/fetch_remote_status_service.rb b/app/services/fetch_remote_status_service.rb
index 54ac3006e..e4537d61f 100644
--- a/app/services/fetch_remote_status_service.rb
+++ b/app/services/fetch_remote_status_service.rb
@@ -11,7 +11,9 @@ class FetchRemoteStatusService < BaseService
   def process_atom(url, body)
     Rails.logger.debug "Processing Atom for remote status at #{url}"
 
-    xml     = Nokogiri::XML(body)
+    xml = Nokogiri::XML(body)
+    xml.encoding = 'utf-8'
+
     account = extract_author(url, xml)
 
     return nil if account.nil?
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 2a9b0a62f..b671c809d 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -4,6 +4,7 @@ class ProcessFeedService < BaseService
 
   def call(body, account)
     xml = Nokogiri::XML(body)
+    xml.encoding = 'utf-8'
 
     update_author(xml, account)
     process_entries(xml, account)
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 06c8f66d2..be78ebb58 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -6,7 +6,9 @@ class ProcessInteractionService < BaseService
   # @param [Account] target_account Account the Salmon was addressed to
   def call(envelope, target_account)
     body = salmon.unpack(envelope)
-    xml  = Nokogiri::XML(body)
+
+    xml = Nokogiri::XML(body)
+    xml.encoding = 'utf-8'
 
     return unless contains_author?(xml)