Skip to content

Commit

Permalink
Explicitly format timestamp in SignatureVerificationError message (#1262
Browse files Browse the repository at this point in the history
)

When interpolating a Time object in a String, Ruby calls `to_s` under the hood.

For Rails applications defining a `default` string format, this triggers deprecation warnings as of v7.0.7: rails/rails#48555

This change fixes that by explicitly formatting the timestamp (using the same `YYYY-MM-DD HH:mm:ss` format currently implicitly used).
  • Loading branch information
magni- authored Aug 22, 2023
1 parent 011f312 commit 79463b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/stripe/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def self.verify_header(payload, header, secret, tolerance: nil)
end

if tolerance && timestamp < Time.now - tolerance
formatted_timestamp = Time.at(timestamp).strftime("%F %T")
raise SignatureVerificationError.new(
"Timestamp outside the tolerance zone (#{Time.at(timestamp)})",
"Timestamp outside the tolerance zone (#{formatted_timestamp})",
header, http_body: payload
)
end
Expand Down

0 comments on commit 79463b2

Please sign in to comment.