Skip to content

Commit

Permalink
Force utf-8 encoding when processing XML
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Nov 13, 2016
1 parent 50d3083 commit 7ce4670
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/services/fetch_remote_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def call(url)
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
Expand Down
4 changes: 3 additions & 1 deletion app/services/fetch_remote_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def call(url)
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?
Expand Down
1 change: 1 addition & 0 deletions app/services/process_feed_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/services/process_interaction_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7ce4670

Please sign in to comment.