Improve shared status verification (#2525)
* Instead of parsing shared status contents verbatim, make roundtrip to purported original URL. Confirm that the "original" URL is from the same domain as the author it claims to be from. * Fix obvious typo, add comment * Use URI look-up first * Add test, update Goldfinger dependency to make less useless HTTP requests per Webfinger lookup
This commit is contained in:
@ -47,8 +47,8 @@ class ProcessFeedService < BaseService
|
||||
return status unless just_created
|
||||
|
||||
if verb == :share
|
||||
original_status, = status_from_xml(@xml.at_xpath('.//activity:object', activity: TagManager::AS_XMLNS))
|
||||
status.reblog = original_status
|
||||
original_status = shared_status_from_xml(@xml.at_xpath('.//activity:object', activity: TagManager::AS_XMLNS))
|
||||
status.reblog = original_status
|
||||
|
||||
if original_status.nil?
|
||||
status.destroy
|
||||
@ -90,6 +90,14 @@ class ProcessFeedService < BaseService
|
||||
!([:post, :share, :delete].include?(verb) && [:activity, :note, :comment].include?(type))
|
||||
end
|
||||
|
||||
def shared_status_from_xml(entry)
|
||||
status = find_status(id(entry))
|
||||
|
||||
return status unless status.nil?
|
||||
|
||||
FetchRemoteStatusService.new.call(url(entry))
|
||||
end
|
||||
|
||||
def status_from_xml(entry)
|
||||
# Return early if status already exists in db
|
||||
status = find_status(id(entry))
|
||||
|
Reference in New Issue
Block a user