sinatra 4.1.0 → 4.2.0
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 +4 -4
- data/CHANGELOG.md +42 -1
- data/Gemfile +1 -0
- data/README.md +42 -24
- data/VERSION +1 -1
- data/lib/sinatra/base.rb +11 -8
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +2 -1
- metadata +7 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 904d7b82f73deaf163b96f2174229e1a2650ee4e152599b8adb4523ecae6a421
|
4
|
+
data.tar.gz: eeba1a0f1198f512a5bb88dc644bf0bbb0d2c1ac4717e20951d8f3a07c4c7d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68108e3688481b30dba13bd485f393a1daa82bcfde6231b827681b59693b7d8363310653d196e43c38513ca60380d29d4f5dc1bd9cb90c838b0d36975af806a4
|
7
|
+
data.tar.gz: ce6ad419d50d6b7862224e2a611a8ea83e03d8f472b89416008de130892fa744aa05a52032a96abb95a4314947cf03a4b1f6cf97aa14519c03ead32361a24512
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## 4.2.0 / 2025-10-08
|
4
|
+
|
5
|
+
* New: Add `:static_headers` setting for custom headers in static file responses ([#2089](https://github.com/sinatra/sinatra/pull/2089))
|
6
|
+
* Fix: Fix regex in `etag_matches?` to prevent ReDoS ([#2121](https://github.com/sinatra/sinatra/pull/2121)))
|
7
|
+
* Fix: `PATH_INFO` can never be empty ([#2114](https://github.com/sinatra/sinatra/pull/2114))
|
8
|
+
* Fix: Fix malformed Content-Type headers ([#2081](https://github.com/sinatra/sinatra/pull/2081))
|
9
|
+
* Fix: Avoid crash for integer values in `content_type` parameters ([#2078](https://github.com/sinatra/sinatra/pull/2078))
|
10
|
+
|
11
|
+
## 4.1.1 / 2024-11-20
|
12
|
+
|
13
|
+
* Fix: Restore WEBrick support ([#2067](https://github.com/sinatra/sinatra/pull/2067))
|
14
|
+
|
1
15
|
## 4.1.0 / 2024-11-18
|
2
16
|
|
3
17
|
* New: Add `host_authorization` setting ([#2053](https://github.com/sinatra/sinatra/pull/2053))
|
4
18
|
* Defaults to `.localhost`, `.test` and any IP address in development mode.
|
5
|
-
* Security: addresses [CVE-
|
19
|
+
* Security: addresses [CVE-2024-21510](https://github.com/advisories/GHSA-hxx2-7vcw-mqr3).
|
6
20
|
* Fix: Return an instance of `Sinatra::IndifferentHash` when calling `#except` ([#2044](https://github.com/sinatra/sinatra/pull/2044))
|
7
21
|
* Fix: Address warning from `URI` for Ruby 3.4 ([#2060](https://github.com/sinatra/sinatra/pull/2060))
|
8
22
|
* Fix: `rackup` no longer depends on WEBrick, recommend Puma instead ([`4a558503`](https://github.com/sinatra/sinatra/commit/4a558503a0ee41f26d4ebc07b478340e8a8a5ed6))
|
@@ -14,6 +28,33 @@
|
|
14
28
|
* Don't depend on `Rack::Logger`
|
15
29
|
* Don't delete `content-length` header when `Rack::Files` is used
|
16
30
|
|
31
|
+
## 4.0.1 / 2025-05-24
|
32
|
+
|
33
|
+
* Rack 3.1 compatibility ([#2035])
|
34
|
+
|
35
|
+
* Fix malformed Content-Type headers ([#2081])
|
36
|
+
|
37
|
+
* Avoid crash for integer values in `content_type` parameters ([#2078])
|
38
|
+
|
39
|
+
* Fix compatibility with --enable-frozen-string-literal ([#2033])
|
40
|
+
|
41
|
+
* Declare missing dependencies for Ruby 3.5 ([#2032])
|
42
|
+
|
43
|
+
* Fix warning about Hash construction. ([#2028])
|
44
|
+
|
45
|
+
* Support Zeitwerk 2.7.0+ ([#2050])
|
46
|
+
|
47
|
+
* Address URI depreciation ([#2060])
|
48
|
+
|
49
|
+
[#2035]: https://github.com/sinatra/sinatra/pull/2035
|
50
|
+
[#2081]: https://github.com/sinatra/sinatra/pull/2081
|
51
|
+
[#2078]: https://github.com/sinatra/sinatra/pull/2078
|
52
|
+
[#2033]: https://github.com/sinatra/sinatra/pull/2033
|
53
|
+
[#2032]: https://github.com/sinatra/sinatra/pull/2032
|
54
|
+
[#2028]: https://github.com/sinatra/sinatra/pull/2028
|
55
|
+
[#2050]: https://github.com/sinatra/sinatra/pull/2050
|
56
|
+
[#2060]: https://github.com/sinatra/sinatra/pull/2060
|
57
|
+
|
17
58
|
## 4.0.0. / 2024-01-19
|
18
59
|
|
19
60
|
* New: Add support for Rack 3 ([#1857])
|
data/Gemfile
CHANGED
@@ -55,6 +55,7 @@ gem 'redcarpet', platforms: [:ruby]
|
|
55
55
|
gem 'simplecov', require: false
|
56
56
|
gem 'slim', '~> 5'
|
57
57
|
gem 'yajl-ruby', platforms: [:ruby]
|
58
|
+
gem 'webrick'
|
58
59
|
|
59
60
|
# sass-embedded depends on google-protobuf
|
60
61
|
# which fails to be installed on JRuby and TruffleRuby under aarch64
|
data/README.md
CHANGED
@@ -34,9 +34,6 @@ Please restart the server every time you change or use a code reloader
|
|
34
34
|
like [rerun](https://github.com/alexch/rerun) or
|
35
35
|
[rack-unreloader](https://github.com/jeremyevans/rack-unreloader).
|
36
36
|
|
37
|
-
It is recommended to also run `gem install puma`, which Sinatra will
|
38
|
-
pick up if available.
|
39
|
-
|
40
37
|
## Table of Contents
|
41
38
|
|
42
39
|
- [Sinatra](#sinatra)
|
@@ -423,6 +420,15 @@ Note that the public directory name is not included in the URL. A file
|
|
423
420
|
Use the `:static_cache_control` setting (see [below](#cache-control)) to add
|
424
421
|
`Cache-Control` header info.
|
425
422
|
|
423
|
+
By default, Sinatra serves static files from the `public/` folder without running middleware or filters. To add custom headers (e.g, for CORS or caching), use the `:static_headers` setting:
|
424
|
+
|
425
|
+
```ruby
|
426
|
+
set :static_headers, {
|
427
|
+
'access-control-allow-origin' => '*',
|
428
|
+
'x-static-asset' => 'served-by-sinatra'
|
429
|
+
}
|
430
|
+
```
|
431
|
+
|
426
432
|
## Views / Templates
|
427
433
|
|
428
434
|
Each template language is exposed via its own rendering method. These
|
@@ -1994,27 +2000,29 @@ set :protection, :session => true
|
|
1994
2000
|
|
1995
2001
|
<dt>host_authorization</dt>
|
1996
2002
|
<dd>
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
<
|
2009
|
-
<
|
2010
|
-
<
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2003
|
+
<p>
|
2004
|
+
You can pass a hash of options to <tt>host_authorization</tt>,
|
2005
|
+
to be used by the <tt>Rack::Protection::HostAuthorization</tt> middleware.
|
2006
|
+
</p>
|
2007
|
+
<p>
|
2008
|
+
The middleware can block requests with unrecognized hostnames, to prevent DNS rebinding
|
2009
|
+
and other host header attacks. It checks the <tt>Host</tt>, <tt>X-Forwarded-Host</tt>
|
2010
|
+
and <tt>Forwarded</tt> headers.
|
2011
|
+
</p>
|
2012
|
+
<p>
|
2013
|
+
Useful options are:
|
2014
|
+
<ul>
|
2015
|
+
<li><tt>permitted_hosts</tt> – an array of hostnames (and <tt>IPAddr</tt> objects) your app recognizes
|
2016
|
+
<ul>
|
2017
|
+
<li>in the <tt>development</tt> environment, it is set to <tt>.localhost</tt>, <tt>.test</tt> and any IPv4/IPv6 address</li>
|
2018
|
+
<li>if empty, any hostname is permitted (the default for any other environment)</li>
|
2019
|
+
</ul>
|
2020
|
+
</li>
|
2021
|
+
<li><tt>status</tt> – the HTTP status code used in the response when a request is blocked (defaults to <tt>403</tt>)</li>
|
2022
|
+
<li><tt>message</tt> – the body used in the response when a request is blocked (defaults to <tt>Host not permitted</tt>)</li>
|
2023
|
+
<li><tt>allow_if</tt> – supply a <tt>Proc</tt> to use custom allow/deny logic, the proc is passed the request environment</li>
|
2024
|
+
</ul>
|
2025
|
+
</p>
|
2018
2026
|
</dd>
|
2019
2027
|
|
2020
2028
|
<dt>logging</dt>
|
@@ -2158,6 +2166,16 @@ set :protection, :session => true
|
|
2158
2166
|
<tt>set :static_cache_control, [:public, :max_age => 300]</tt>
|
2159
2167
|
</dd>
|
2160
2168
|
|
2169
|
+
<dt>static_headers</dt>
|
2170
|
+
<dd>
|
2171
|
+
Allows you to define custom header settings for static file responses.
|
2172
|
+
</dd>
|
2173
|
+
<dd>
|
2174
|
+
For example: <br>
|
2175
|
+
<tt>set :static_headers, {'access-control-allow-origin' => '*', 'x-static-asset' => 'served-by-sinatra'}</tt>
|
2176
|
+
</dd>
|
2177
|
+
|
2178
|
+
|
2161
2179
|
<dt>threaded</dt>
|
2162
2180
|
<dd>
|
2163
2181
|
If set to <tt>true</tt>, will tell server to use
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.2.0
|
data/lib/sinatra/base.rb
CHANGED
@@ -396,11 +396,11 @@ module Sinatra
|
|
396
396
|
end
|
397
397
|
params.delete :charset if mime_type.include? 'charset'
|
398
398
|
unless params.empty?
|
399
|
-
mime_type <<
|
399
|
+
mime_type << ';'
|
400
400
|
mime_type << params.map do |key, val|
|
401
|
-
val = val.inspect if val =~ /[";,]/
|
401
|
+
val = val.inspect if val.to_s =~ /[";,]/
|
402
402
|
"#{key}=#{val}"
|
403
|
-
end.join('
|
403
|
+
end.join(';')
|
404
404
|
end
|
405
405
|
response['content-type'] = mime_type
|
406
406
|
end
|
@@ -711,7 +711,7 @@ module Sinatra
|
|
711
711
|
def etag_matches?(list, new_resource = request.post?)
|
712
712
|
return !new_resource if list == '*'
|
713
713
|
|
714
|
-
list.to_s.split(
|
714
|
+
list.to_s.split(',').map(&:strip).include?(response['ETag'])
|
715
715
|
end
|
716
716
|
|
717
717
|
def with_params(temp_params)
|
@@ -1099,7 +1099,6 @@ module Sinatra
|
|
1099
1099
|
# Returns pass block.
|
1100
1100
|
def process_route(pattern, conditions, block = nil, values = [])
|
1101
1101
|
route = @request.path_info
|
1102
|
-
route = '/' if route.empty? && !settings.empty_path_info?
|
1103
1102
|
route = route[0..-2] if !settings.strict_paths? && route != '/' && route.end_with?('/')
|
1104
1103
|
|
1105
1104
|
params = pattern.params(route)
|
@@ -1143,6 +1142,7 @@ module Sinatra
|
|
1143
1142
|
|
1144
1143
|
# Attempt to serve static files from public directory. Throws :halt when
|
1145
1144
|
# a matching file is found, returns nil otherwise.
|
1145
|
+
# If custom static headers are defined, use them.
|
1146
1146
|
def static!(options = {})
|
1147
1147
|
return if (public_dir = settings.public_folder).nil?
|
1148
1148
|
|
@@ -1156,6 +1156,9 @@ module Sinatra
|
|
1156
1156
|
|
1157
1157
|
env['sinatra.static_file'] = path
|
1158
1158
|
cache_control(*settings.static_cache_control) if settings.static_cache_control?
|
1159
|
+
|
1160
|
+
headers(settings.static_headers) if settings.static_headers?
|
1161
|
+
|
1159
1162
|
send_file path, options.merge(disposition: nil)
|
1160
1163
|
end
|
1161
1164
|
|
@@ -1772,7 +1775,6 @@ module Sinatra
|
|
1772
1775
|
end
|
1773
1776
|
|
1774
1777
|
def route(verb, path, options = {}, &block)
|
1775
|
-
enable :empty_path_info if path == '' && empty_path_info.nil?
|
1776
1778
|
signature = compile!(verb, path, block, **options)
|
1777
1779
|
(@routes[verb] ||= []) << signature
|
1778
1780
|
invoke_hook(:route_added, verb, path, block)
|
@@ -1969,7 +1971,7 @@ module Sinatra
|
|
1969
1971
|
set :running_server, nil
|
1970
1972
|
set :handler_name, nil
|
1971
1973
|
set :traps, true
|
1972
|
-
set :server, %w[]
|
1974
|
+
set :server, %w[webrick]
|
1973
1975
|
set :bind, proc { development? ? 'localhost' : '0.0.0.0' }
|
1974
1976
|
set :port, Integer(ENV['PORT'] && !ENV['PORT'].empty? ? ENV['PORT'] : 4567)
|
1975
1977
|
set :quiet, false
|
@@ -1998,7 +2000,6 @@ module Sinatra
|
|
1998
2000
|
|
1999
2001
|
set :absolute_redirects, true
|
2000
2002
|
set :prefixed_redirects, false
|
2001
|
-
set :empty_path_info, nil
|
2002
2003
|
set :strict_paths, true
|
2003
2004
|
|
2004
2005
|
set :app_file, nil
|
@@ -2011,6 +2012,8 @@ module Sinatra
|
|
2011
2012
|
set :public_folder, proc { root && File.join(root, 'public') }
|
2012
2013
|
set :static, proc { public_folder && File.exist?(public_folder) }
|
2013
2014
|
set :static_cache_control, false
|
2015
|
+
|
2016
|
+
set :static_headers, {}
|
2014
2017
|
|
2015
2018
|
error ::Exception do
|
2016
2019
|
response.status = 500
|
data/lib/sinatra/version.rb
CHANGED
data/sinatra.gemspec
CHANGED
@@ -40,7 +40,8 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
|
|
40
40
|
'homepage_uri' => 'http://sinatrarb.com/',
|
41
41
|
'bug_tracker_uri' => 'https://github.com/sinatra/sinatra/issues',
|
42
42
|
'mailing_list_uri' => 'http://groups.google.com/group/sinatrarb',
|
43
|
-
'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
|
43
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra',
|
44
|
+
'rubygems_mfa_required' => 'true',
|
44
45
|
}
|
45
46
|
|
46
47
|
s.required_ruby_version = '>= 2.7.8'
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
8
8
|
- Ryan Tomayko
|
9
9
|
- Simon Rozet
|
10
10
|
- Konstantin Haase
|
11
|
-
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: logger
|
@@ -67,14 +66,14 @@ dependencies:
|
|
67
66
|
requirements:
|
68
67
|
- - '='
|
69
68
|
- !ruby/object:Gem::Version
|
70
|
-
version: 4.
|
69
|
+
version: 4.2.0
|
71
70
|
type: :runtime
|
72
71
|
prerelease: false
|
73
72
|
version_requirements: !ruby/object:Gem::Requirement
|
74
73
|
requirements:
|
75
74
|
- - '='
|
76
75
|
- !ruby/object:Gem::Version
|
77
|
-
version: 4.
|
76
|
+
version: 4.2.0
|
78
77
|
- !ruby/object:Gem::Dependency
|
79
78
|
name: rack-session
|
80
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,8 +114,8 @@ email: sinatrarb@googlegroups.com
|
|
115
114
|
executables: []
|
116
115
|
extensions: []
|
117
116
|
extra_rdoc_files:
|
118
|
-
- README.md
|
119
117
|
- LICENSE
|
118
|
+
- README.md
|
120
119
|
files:
|
121
120
|
- ".yardopts"
|
122
121
|
- AUTHORS.md
|
@@ -153,7 +152,7 @@ metadata:
|
|
153
152
|
bug_tracker_uri: https://github.com/sinatra/sinatra/issues
|
154
153
|
mailing_list_uri: http://groups.google.com/group/sinatrarb
|
155
154
|
documentation_uri: https://www.rubydoc.info/gems/sinatra
|
156
|
-
|
155
|
+
rubygems_mfa_required: 'true'
|
157
156
|
rdoc_options:
|
158
157
|
- "--line-numbers"
|
159
158
|
- "--title"
|
@@ -174,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
173
|
- !ruby/object:Gem::Version
|
175
174
|
version: '0'
|
176
175
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
178
|
-
signing_key:
|
176
|
+
rubygems_version: 3.6.9
|
179
177
|
specification_version: 4
|
180
178
|
summary: Classy web-development dressed in a DSL
|
181
179
|
test_files: []
|