File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ def from_node(node, attachable = nil)
1212
1313 def attachable_from_possibly_expired_sgid ( sgid )
1414 if message = sgid &.split ( "--" ) &.first
15- encoded_message = JSON . parse Base64 . strict_decode64 ( message )
15+ encoded_message = JSON . parse ( decode_base64 ( message ) )
1616
1717 decoded_gid = if data = encoded_message . dig ( "_rails" , "data" )
1818 data
1919 elsif data = encoded_message . dig ( "_rails" , "message" )
2020 # Rails 7 used an older format of GID that serialized the payload using Marshall
2121 # Since we intentionally skip signature verification, we can't safely unmarshal the data
2222 # To work around this, we manually extract the GID from the marshaled data
23- Base64 . urlsafe_decode64 ( data ) . match ( %r{(gid://campfire/[^/]+/\d +)} ) &.to_s
23+ decode_base64 ( data ) . match ( %r{(gid://campfire/[^/]+/\d +)} ) &.to_s
2424 else
2525 nil
2626 end
@@ -32,6 +32,12 @@ def attachable_from_possibly_expired_sgid(sgid)
3232 rescue ActiveRecord ::RecordNotFound
3333 nil
3434 end
35+
36+ def decode_base64 ( message )
37+ Base64 . strict_decode64 ( message )
38+ rescue => _e
39+ Base64 . urlsafe_decode64 ( message )
40+ end
3541 end
3642 end
3743end
You can’t perform that action at this time.
0 commit comments