mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-26 15:46:47 +09:00
Parse Rails 7 GIDs
This commit is contained in:
1 parent
13897eac59
commit
bebe518c74
2 files changed
+47
-3
No files matched your search
@@ -16,13 +16,18 @@ ActiveSupport.on_load(:action_text_content) do
|
||||
|
||||
decoded_gid = if data = encoded_message.dig("_rails", "data")
|
||||
data
|
||||
elsif data = encoded_message.dig("_rails", "message")
|
||||
# Rails 7 used an older format of GID that serialized the payload using Marshall
|
||||
# Since we intentionally skip signature verification, we can't safely unmarshal the data
|
||||
# To work around this, we manually extract the GID from the marshaled data
|
||||
Base64.strict_decode64(data).match(%r{(gid://campfire/[^/]+/\d+)})&.to_s
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
model = GlobalID.find(decoded_gid)
|
||||
|
||||
model.model_name.to_s.in?(ATTACHABLES_PERMITTED_WITH_INVALID_SIGNATURES) ? model : nil
|
||||
if model = GlobalID.find(decoded_gid)
|
||||
model.model_name.to_s.in?(ATTACHABLES_PERMITTED_WITH_INVALID_SIGNATURES) ? model : nil
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
nil
|
||||
|
||||
Reference in new issue
Block a user