sinatra-contrib 4.2.1 → 4.2.2

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: ad046c78c03b722938e6897e248024cc5659033f535ee0e1e7324ef7797400fc
4
- data.tar.gz: bda55fd34daee12777382f5b901eff85cf004a9b0e89c8f54b3df5521605620f
3
+ metadata.gz: 6cebaa00078a2b2de2591b9d59c57a8e9b4397bdb9b7407e7fab6b121b8084b3
4
+ data.tar.gz: 202e01d903046c7e6ca1876a36101c1e91029413fcd5a3bfca34682260bfe7a0
5
5
  SHA512:
6
- metadata.gz: f4e51e787f060c5a48a14eaaeeb74bd8c3728abdd73dff4b96d1f0186bfa1116b2ba312755d2a5229d94a665344705ca8a656afa729e94b5cc8071f15c868e8a
7
- data.tar.gz: d89b78e6ab6047fb1e22c51d9d4189b755abb97615f6d2fc9ec7dde159f7c92d02e65d8385eee2ae593ca642d46bda20c70fefd84844db196522680e1871f5cb
6
+ metadata.gz: dc42d2b959a979d389c0c752da0104172dfc802dcb5a4da01b373c71571dbbb97a7fca2c6d49e766bd5ca2c7f2e29658daa63faf6e465373c543b72b791b9fad
7
+ data.tar.gz: 8113ec07d11aff659a1c9e9276f16f8c773b52b716f874b0dbfddab0ef541c26a311e876469018487545bfd70eac23728d55964997e88f32960ab33b61d5414e
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sinatra
4
4
  module Contrib
5
- VERSION = '4.2.1'
5
+ VERSION = '4.2.2'
6
6
  end
7
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rack/protection'
4
+
3
5
  module Sinatra
4
6
  # = Sinatra::QuietLogger
5
7
  #
@@ -34,6 +36,8 @@ module Sinatra
34
36
  # end
35
37
  #
36
38
  module QuietLogger
39
+ PATH_TRAVERSAL = ::Rack::Protection::PathTraversal.new(nil)
40
+
37
41
  def self.registered(app)
38
42
  quiet_logger_prefixes = begin
39
43
  app.settings.quiet_logger_prefixes.join('|')
@@ -42,14 +46,29 @@ module Sinatra
42
46
  end
43
47
  return warn('You need to specify the paths you wish to exclude from logging via `set :quiet_logger_prefixes, %w(images css fonts)`') if quiet_logger_prefixes.empty?
44
48
 
49
+ @app = app
45
50
  const_set('QUIET_LOGGER_REGEX', %r(\A/{0,2}(?:#{quiet_logger_prefixes})))
46
51
  ::Rack::CommonLogger.prepend(
47
52
  ::Module.new do
48
53
  def log(env, *)
49
- super unless env['PATH_INFO'] =~ QUIET_LOGGER_REGEX
54
+ super unless QuietLogger.routed_path(env['PATH_INFO'].to_s) =~ QUIET_LOGGER_REGEX
50
55
  end
51
56
  end
52
57
  )
53
58
  end
59
+
60
+ # The path the app matched its routes on. Rack::Protection::PathTraversal
61
+ # cleans the path for the app only, when the request is logged PATH_INFO
62
+ # is back to what the client sent.
63
+ def self.routed_path(path)
64
+ path_traversal? ? PATH_TRAVERSAL.cleanup(path) : path
65
+ end
66
+
67
+ # Checked for each request, protection can be set after registering
68
+ def self.path_traversal?
69
+ protection = @app.protection
70
+ except = protection[:except] if protection.is_a?(Hash)
71
+ @app.protection? && !Array(except).include?(:path_traversal)
72
+ end
54
73
  end
55
74
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- version = File.read(File.expand_path('../VERSION', __dir__)).strip
3
+ require_relative 'lib/sinatra/contrib/version'
4
+
5
+ version = Sinatra::Contrib::VERSION
4
6
 
5
7
  Gem::Specification.new do |s|
6
8
  s.name = 'sinatra-contrib'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/sinatra/sinatra/graphs/contributors
@@ -43,28 +43,28 @@ dependencies:
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 4.2.1
46
+ version: 4.2.2
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 4.2.1
53
+ version: 4.2.2
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: sinatra
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - '='
59
59
  - !ruby/object:Gem::Version
60
- version: 4.2.1
60
+ version: 4.2.2
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - '='
66
66
  - !ruby/object:Gem::Version
67
- version: 4.2.1
67
+ version: 4.2.2
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: tilt
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.6.9
139
+ rubygems_version: 4.0.20
140
140
  specification_version: 4
141
141
  summary: Collection of useful Sinatra extensions.
142
142
  test_files: []