From e4a241abefaa68492938c3fbb7e5e5401d12138e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 8 Jan 2018 05:00:23 +0100 Subject: Fix bad URL schemes being accepted (#6219) * Fix actors accepting invalid URI schemes or different host between URI and URL * Fix statuses accepting invalid URI scheme or different host to actor * Adjust tests to new requirements * Improve readability of mismatching_origin?/invalid_origin? methods --- app/helpers/jsonld_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index 6c7c38070..9530ad9f3 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -39,6 +39,10 @@ module JsonLdHelper !json.nil? && equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT) end + def unsupported_uri_scheme?(uri) + !uri.start_with?('http://', 'https://') + end + def canonicalize(json) graph = RDF::Graph.new << JSON::LD::API.toRdf(json) graph.dump(:normalize) -- cgit