stripe 19.6.0 → 19.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82286b48db91166e11aef358ae27fcffab4b855b9e9ae9f3b524e27745551ff0
4
- data.tar.gz: f8f624933606ae7251b345d614bd61d7555bb4ccd4220c0fe738c00362ce487c
3
+ metadata.gz: 2658d175c0e9668ca5effb73396f22b9f19a3df059558de5ae56912db9e9547a
4
+ data.tar.gz: 29e5fb8e31fa57e3011a24117be58d99eb0f06d1385014ba135df1a936abe7db
5
5
  SHA512:
6
- metadata.gz: 4241e97de04950962a14bbdb988c428148bca9abad2be29d0abc761673485b7c6e622b914cfe4cfb118ec6abb1ccaebb60ea2eec4705d06aa2099642008f23c4
7
- data.tar.gz: a1565300b92248d840a3aeef3fefb399572de194e81fc2e4aebb66576cf9d64847ae0bd8dfa7fbc9774e80d570660573fdd88f247c654b2404b22e837b843e98
6
+ metadata.gz: 2a55bcb93a02feb6f0f766bf10ef9fde2a30be1535bead833583cbb24e49e9ca791ab0910a02d957f66bb2b1bec5e701ba8e330554a0a9536036cbed79e516e7
7
+ data.tar.gz: e992a203be967077d537facef9323182a643d6004197b7d563a93a98c79fb745283d6b8c23526fae44b0067f5f9f994e5e26e8ff17ac3228cd883a93393aedbf
@@ -462,13 +462,13 @@ module Stripe
462
462
  private def execute_request_internal(method, path,
463
463
  base_address, params, opts, usage,
464
464
  &read_body_chunk_block)
465
+ Util.validate_path!(path)
466
+
465
467
  api_mode = Util.get_api_mode(path)
466
468
  opts = RequestOptions.merge_config_and_opts(config, opts)
467
469
 
468
470
  raise ArgumentError, "method should be a symbol" \
469
471
  unless method.is_a?(Symbol)
470
- raise ArgumentError, "path should be a string" \
471
- unless path.is_a?(String)
472
472
 
473
473
  base_url ||= config.base_addresses[base_address]
474
474
 
@@ -53,9 +53,12 @@ module Stripe
53
53
 
54
54
  # Retrieves the Event that generated this EventNotification.
55
55
  def fetch_event
56
- resp = @client.raw_request(:get, "/v2/core/events/#{id}", opts: { stripe_context: context,
57
- "Stripe-Request-Trigger" => "event=#{id}", },
58
- usage: ["fetch_event"])
56
+ # `id` comes from the notification body, so escape it the way generated
57
+ # services do -- otherwise it can inject extra path or query segments.
58
+ path = "/v2/core/events/#{CGI.escape(id)}"
59
+ resp = @client.raw_request(:get, path, opts: { stripe_context: context,
60
+ "Stripe-Request-Trigger" => "event=#{id}", },
61
+ usage: ["fetch_event"])
59
62
  @client.deserialize(resp.http_body, api_mode: :v2)
60
63
  end
61
64
  end
@@ -11,7 +11,7 @@ module Stripe
11
11
 
12
12
  params[:client_id] = client_id(params)
13
13
 
14
- params[:response_type] = "code" if params.include?(:response_type)
14
+ params[:response_type] ||= "code"
15
15
 
16
16
  query = Util.encode_parameters(params, :v1)
17
17
 
data/lib/stripe/util.rb CHANGED
@@ -375,6 +375,38 @@ module Stripe
375
375
  res.zero?
376
376
  end
377
377
 
378
+ # Asserts that a request path is origin-relative: that it begins with a
379
+ # single "/" and carries no scheme, authority or userinfo.
380
+ #
381
+ # The absolute URL is built by concatenating a base address onto this path,
382
+ # and no base address ends in a slash. A path like "@evil.example/v1/x" or
383
+ # ".evil.example/v1/x" would modify the resulting host and direct the request
384
+ # (including the API key) to a non-Stripe host.
385
+ #
386
+ # Because some relative urls arrive from potentially untrusted sources (like
387
+ # webhook bodies), we have to be a little defensive.
388
+ #
389
+ # So, we require that a path starts with a leading slash and that URI.parse
390
+ # finds no scheme or authority in it.
391
+ def self.validate_path!(path)
392
+ unless path.is_a?(String) && path.start_with?("/") && !path.start_with?("//")
393
+ raise ArgumentError,
394
+ "path must be a string beginning with a single \"/\", got: #{path.inspect}"
395
+ end
396
+
397
+ uri =
398
+ begin
399
+ URI.parse(path)
400
+ rescue URI::InvalidURIError
401
+ raise ArgumentError, "path is not a valid URI: #{path.inspect}"
402
+ end
403
+
404
+ return if uri.scheme.nil? && uri.host.nil? && uri.userinfo.nil?
405
+
406
+ raise ArgumentError,
407
+ "path may not contain a scheme or authority, got: #{path.inspect}"
408
+ end
409
+
378
410
  # Returns either v1 or v2 as api_mode based on the given path
379
411
  def self.get_api_mode(path)
380
412
  if path.start_with?("/v2/")
@@ -80,7 +80,8 @@ module Stripe
80
80
  _request(
81
81
  method: :get,
82
82
  path: next_page_url,
83
- base_address: :api
83
+ base_address: :api,
84
+ opts: opts
84
85
  )
85
86
  end
86
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "19.6.0"
4
+ VERSION = "19.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.6.0
4
+ version: 19.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-27 00:00:00.000000000 Z
11
+ date: 2026-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal