about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-22 20:55:14 +0200
committerGitHub <noreply@github.com>2018-08-22 20:55:14 +0200
commit802cf6a4c53175c7da17ded39cf75679fa352385 (patch)
treeea3833a78c7282626f58475175d491254a64e0d8 /app/helpers
parentad41806e53e6b024aaca01d1d59fcc82d1c4b804 (diff)
Improve federated ID validation (#8372)
* Fix URI not being sufficiently validated with prefetched JSON

* Add additional id validation to OStatus documents, when possible
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/jsonld_helper.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb
index 9d2b6cf00..532397272 100644
--- a/app/helpers/jsonld_helper.rb
+++ b/app/helpers/jsonld_helper.rb
@@ -73,8 +73,10 @@ module JsonLdHelper
     end
   end
 
-  def body_to_json(body)
-    body.is_a?(String) ? Oj.load(body, mode: :strict) : body
+  def body_to_json(body, compare_id: nil)
+    json = body.is_a?(String) ? Oj.load(body, mode: :strict) : body
+    return if compare_id.present? && json['id'] != compare_id
+    json
   rescue Oj::ParseError
     nil
   end