]> cat aescling's git repositories - mastodon.git/commitdiff
Fix invalid blurhash handling in Create activity (#16583)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Mon, 9 Aug 2021 11:33:19 +0000 (20:33 +0900)
committerGitHub <noreply@github.com>
Mon, 9 Aug 2021 11:33:19 +0000 (13:33 +0200)
app/lib/activitypub/activity/create.rb

index 504f10a67eafc456457b8df39a4af0bde417dbb1..4c13a80a6702e0a7f4c7f7ca92aa86ad4f8a4a03 100644 (file)
@@ -446,10 +446,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
   end
 
   def supported_blurhash?(blurhash)
-    components = blurhash.blank? ? nil : Blurhash.components(blurhash)
+    components = blurhash.blank? || !blurhash_valid_chars?(blurhash) ? nil : Blurhash.components(blurhash)
     components.present? && components.none? { |comp| comp > 5 }
   end
 
+  def blurhash_valid_chars?(blurhash)
+    /^[\w#$%*+-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
+  end
+
   def skip_download?
     return @skip_download if defined?(@skip_download)