1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-24 15:16:33 +09:00

Fix invalid blurhash handling in Create activity (#16583)

This commit is contained in:
Takeshi Umeda 2021-08-09 20:33:19 +09:00 committed by GitHub
parent 590e1578bf
commit 709876bd6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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)