Force utf-8 encoding when processing XML

This commit is contained in:
Eugen Rochko 2016-11-13 19:12:40 +01:00
parent 50d3083cbd
commit 7ce4670164
4 changed files with 10 additions and 3 deletions

View File

@ -10,6 +10,8 @@ class FetchRemoteAccountService < BaseService
def process_atom(url, body) def process_atom(url, body)
xml = Nokogiri::XML(body) xml = Nokogiri::XML(body)
xml.encoding = 'utf-8'
url_parts = Addressable::URI.parse(url) url_parts = Addressable::URI.parse(url)
username = xml.at_xpath('//xmlns:author/xmlns:name').try(:content) username = xml.at_xpath('//xmlns:author/xmlns:name').try(:content)
domain = url_parts.host domain = url_parts.host

View File

@ -12,6 +12,8 @@ class FetchRemoteStatusService < BaseService
Rails.logger.debug "Processing Atom for remote status at #{url}" 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) account = extract_author(url, xml)
return nil if account.nil? return nil if account.nil?

View File

@ -4,6 +4,7 @@ class ProcessFeedService < BaseService
def call(body, account) def call(body, account)
xml = Nokogiri::XML(body) xml = Nokogiri::XML(body)
xml.encoding = 'utf-8'
update_author(xml, account) update_author(xml, account)
process_entries(xml, account) process_entries(xml, account)

View File

@ -6,7 +6,9 @@ class ProcessInteractionService < BaseService
# @param [Account] target_account Account the Salmon was addressed to # @param [Account] target_account Account the Salmon was addressed to
def call(envelope, target_account) def call(envelope, target_account)
body = salmon.unpack(envelope) body = salmon.unpack(envelope)
xml = Nokogiri::XML(body) xml = Nokogiri::XML(body)
xml.encoding = 'utf-8'
return unless contains_author?(xml) return unless contains_author?(xml)