1
0
Fork 0
forked from gitea/nas

Add support for importing embedded self-quotes (#34584)

This commit is contained in:
Claire 2025-05-05 10:01:16 +02:00 committed by GitHub
parent d41a741e00
commit cbaba54e9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 67 additions and 16 deletions

View file

@ -72,6 +72,18 @@ module JsonLdHelper
!haystack.casecmp(needle).zero?
end
def safe_prefetched_embed(account, object, context)
return unless object.is_a?(Hash)
# NOTE: Replacing the object's context by that of the parent activity is
# not sound, but it's consistent with the rest of the codebase
object = object.merge({ '@context' => context })
return if value_or_id(first_of_value(object['attributedTo'])) != account.uri || non_matching_uri_hosts?(account.uri, object['id'])
object
end
def canonicalize(json)
graph = RDF::Graph.new << JSON::LD::API.toRdf(json, documentLoader: method(:load_jsonld_context))
graph.dump(:normalize)