sinatra 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: 273dc42d5989e8186e18f3c93f386454a4c63ffa1e8da672e9d5f91a4e1ea1e5
4
- data.tar.gz: 66a2357e2aab7d0acd8a780f692ce66286eb806175199fc7ccd421267b29bf4c
3
+ metadata.gz: d8d930fc192c65035b00a24e7bcf7c17c123195a9d7457f459b568dfe37e1fb6
4
+ data.tar.gz: 4731a308af470b4807c4ab922029e975906d420501b6946e00d2a563e2634dcf
5
5
  SHA512:
6
- metadata.gz: 4a30a3cb2dad00c6c54c9ecf57066f2810e9599a1c612ecea5da910913d1380ca0307e6ed4897eb3d2cedba7faff3d225bb52c6b4975d3f9d2a120fe8d08a304
7
- data.tar.gz: 3c241fe8a0613f29af44ed93d416fdc647febf9e0b4c725c8bc15d8328f98701181f3a01d2c8dc4987aa08a44d7b7501722945c10041ea0f37b732c4d894f5ae
6
+ metadata.gz: 5a0e020e65ab778d6819aebc45ca043332fefc45c98f192b76f485998c874404b8e6466d93107811e4e982bf6786bdf17ab836d48f70d30c38ee8365711c5c24
7
+ data.tar.gz: 939f0733479cdac308049fbe126b7bbddbb7eb492602290e5e07457284a635adc302f8c2a4dea947b9cf9e2ad91d18e4938d1621552965690253aafbdec25f2c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 4.2.2 / 2026-11-17
4
+
5
+ * Fix: Require a dot before the domain for leading-dot `permitted_hosts` in `Rack::Protection::HostAuthorization`
6
+ * `.example.org` no longer permits hosts that only end in `example.org`, like `evilexample.org`
7
+ * Fix: Do not treat a missing `Referer` as same-origin when `Sec-Fetch-Site` says the request is cross-site or same-site
8
+ * Affects `RemoteToken`, `JsonCsrf` and `RemoteReferrer` in `Rack::Protection`
9
+ * Requests with neither header are accepted as before, `allow_empty_referrer` still defaults to `true`
10
+ * Fix: `Rack::Protection::CookieTossing` no longer rejects all requests after one with duplicate session cookies
11
+ * Docs: Document that static files are served through symlinks pointing outside `public_folder`
12
+ * Fix: `Sinatra::QuietLogger` no longer hides requests that are routed outside the quiet prefixes
13
+ * `/images/../admin` is routed to `/admin`, so it is now logged even with `images` as a quiet prefix
14
+ * Fix: Set `Strict-Transport-Security` and `Referrer-Policy` on responses rejected by other protections
15
+ * Only for apps that use `strict_transport` or `referrer_policy`, neither is enabled by default
16
+ * Responses rejected by `AuthenticityToken`, `FormToken` or `CookieTossing` now have both headers, those rejected by `RemoteReferrer` or `SessionHijacking` now have `Strict-Transport-Security`
17
+ * Requests are accepted and rejected as before, so nothing changes with the `drop_session` reaction, the default in Sinatra, as it does not reject requests
18
+ * A header already set on the response is kept
19
+ * Fix: Run `Rack::Protection::PathTraversal` before the other protections
20
+ * All protections now see the normalized path, the one the app routes on, where some saw the path as it was sent
21
+ * Only requests with a path that gets normalized are affected: `.` or `..` segments, `%2e`, `%2f`, `%5c`, backslashes or repeated slashes
22
+ * Check code written for the path as it was sent: an `allow_if` matching `/webhooks/[^/]+` no longer matches `/webhooks/a%2Fb`, as it is called with `/webhooks/a/b`
23
+
24
+ | What | Before | After |
25
+ | --- | --- | --- |
26
+ | `allow_if` of `AuthenticityToken`, `FormToken`, `HttpOrigin` and `JsonCsrf` | called with the path as it was sent | called with the normalized path |
27
+ | `instrumenter` of the protections that ran before `PathTraversal` | notified with the path as it was sent | notified with the normalized path |
28
+ | Per-form tokens of `AuthenticityToken` and `FormToken` | checked against the path as it was sent | checked against the normalized path |
29
+ | `CookieTossing` | redirected to, and expired cookies for, the path as it was sent | uses the normalized path |
30
+ | `RemoteToken`, `XSSHeader` and middleware added with `use` | saw the normalized path | unchanged |
31
+
32
+ * Fix: `rack-protection` and `sinatra-contrib` used from a path source no longer fail to load after `bundle cache` ([#2144](https://github.com/sinatra/sinatra/pull/2144))
33
+ * Fix: Avoid "method redefined" warnings in `Sinatra::Delegator` ([#2139](https://github.com/sinatra/sinatra/pull/2139))
34
+
3
35
  ## 4.2.1 / 2025-10-10
4
36
 
5
37
  * Fix: Revert "`PATH_INFO` can never be empty" ([#2124](https://github.com/sinatra/sinatra/pull/2124))
data/CONTRIBUTING.md CHANGED
@@ -56,9 +56,9 @@ track patch requests.
56
56
  is where the website sources are managed. There are almost always people in
57
57
  `#sinatra` that are happy to discuss, apply, and publish website patches.
58
58
 
59
- * [The Book](http://sinatra-org-book.herokuapp.com/) has its own [Git
60
- repository](http://github.com/sinatra/sinatra-book/) and build process but is
61
- managed the same as the website and project codebase.
59
+ * [The Book](https://github.com/sinatra/sinatra-book) has its own Git
60
+ repository and build process but is managed the same as the website and
61
+ project codebase.
62
62
 
63
63
  * [Sinatra Recipes](http://recipes.sinatrarb.com/) is a community
64
64
  project where anyone is free to contribute ideas, recipes and tutorials. Which
data/Gemfile CHANGED
@@ -34,14 +34,17 @@ gem 'yard' # used by rake doc
34
34
  gem 'rack-protection', path: 'rack-protection'
35
35
  gem 'sinatra-contrib', path: 'sinatra-contrib'
36
36
 
37
+ # eventmachine and yajl-ruby use the Data_Wrap_Struct C API, which was removed
38
+ # in Ruby 4.1, so they fail to compile there. Their tests skip without them.
39
+ legacy_c_api = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('4.1')
40
+
37
41
  gem 'asciidoctor'
38
42
  gem 'builder'
39
43
  gem 'childprocess', '>= 5'
40
- gem 'commonmarker', '~> 0.23.4', platforms: [:ruby]
41
44
  gem 'erubi'
42
- gem 'eventmachine'
45
+ gem 'eventmachine' if legacy_c_api
43
46
  gem 'falcon', '~> 0.40', platforms: [:ruby]
44
- gem 'haml', '~> 6'
47
+ gem 'haml'
45
48
  gem 'kramdown'
46
49
  gem 'liquid'
47
50
  gem 'markaby'
@@ -54,7 +57,7 @@ gem 'rdoc'
54
57
  gem 'redcarpet', platforms: [:ruby]
55
58
  gem 'simplecov', require: false
56
59
  gem 'slim', '~> 5'
57
- gem 'yajl-ruby', platforms: [:ruby]
60
+ gem 'yajl-ruby', platforms: [:ruby] if legacy_c_api
58
61
  gem 'webrick'
59
62
 
60
63
  # sass-embedded depends on google-protobuf
@@ -63,4 +66,23 @@ gem 'webrick'
63
66
  # https://github.com/protocolbuffers/protobuf/issues/11935
64
67
  java = %w(jruby truffleruby).include?(RUBY_ENGINE)
65
68
  aarch64 = RbConfig::CONFIG["target_cpu"] == 'aarch64'
66
- gem 'sass-embedded', '~> 1.54' unless java && aarch64
69
+ # sass-embedded has no prebuilt gems for Ruby 3.1, and building it from source
70
+ # in this bundle fails as Ruby 3.1's own psych and json get mixed with the
71
+ # newer psych and json gems. The sass tests skip without it.
72
+ ruby31 = RUBY_VERSION.start_with?('3.1.')
73
+ gem 'sass-embedded', '~> 1.54' unless (java && aarch64) || ruby31
74
+
75
+ # if commonmarker can't be loaded, the commonmarker tests are skipped, that's fine thanks to the big CI matrix
76
+ #
77
+ # jruby does not support native extensions
78
+ # https://github.com/truffleruby/truffleruby/issues/3396#issuecomment-3694252552
79
+ #
80
+ # it is not a guarantee that the rust gems magnus and rb-sys have been updated for ruby-head
81
+ # example for 4.1 dev https://github.com/matsadler/magnus/pull/164, https://github.com/oxidize-rb/rb-sys/pull/697
82
+ #
83
+ # commonmarker 2.0.1 is the last release with prebuilt gems for Ruby 3.1. Newer
84
+ # ones are compiled from source there, and their bundled oniguruma fails to
85
+ # build with GCC 15 (C23 by default), as on ubuntu-26.04.
86
+ ruby_head = RUBY_PATCHLEVEL == -1
87
+ commonmarker_version = ruby31 ? '2.0.1' : nil
88
+ gem 'commonmarker', commonmarker_version unless (java || ruby_head)
data/README.md CHANGED
@@ -417,6 +417,10 @@ Note that the public directory name is not included in the URL. A file
417
417
  `./public/css/style.css` is made available as
418
418
  `http://example.com/css/style.css`.
419
419
 
420
+ Symbolic links inside the public directory are followed, even when they
421
+ point outside of it. Only link to files and directories that are meant to
422
+ be public.
423
+
420
424
  Use the `:static_cache_control` setting (see [below](#cache-control)) to add
421
425
  `Cache-Control` header info.
422
426
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.2.1
1
+ 4.2.2
data/lib/sinatra/base.rb CHANGED
@@ -308,9 +308,7 @@ module Sinatra
308
308
 
309
309
  # Halt processing and redirect to the URI provided.
310
310
  def redirect(uri, *args)
311
- # SERVER_PROTOCOL is required in Rack 3, fall back to HTTP_VERSION
312
- # for servers not updated for Rack 3 (like Puma 5)
313
- http_version = env['SERVER_PROTOCOL'] || env['HTTP_VERSION']
311
+ http_version = env['SERVER_PROTOCOL']
314
312
  if (http_version == 'HTTP/1.1') && (env['REQUEST_METHOD'] != 'GET')
315
313
  status 303
316
314
  else
@@ -2103,6 +2101,8 @@ module Sinatra
2103
2101
  module Delegator # :nodoc:
2104
2102
  def self.delegate(*methods)
2105
2103
  methods.each do |method_name|
2104
+ next if method_defined?(method_name) || private_method_defined?(method_name)
2105
+
2106
2106
  define_method(method_name) do |*args, &block|
2107
2107
  return super(*args, &block) if respond_to? method_name
2108
2108
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sinatra
4
- VERSION = '4.2.1'
4
+ VERSION = '4.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
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
  - Blake Mizerany
@@ -66,14 +66,14 @@ dependencies:
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 4.2.1
69
+ version: 4.2.2
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 4.2.1
76
+ version: 4.2.2
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rack-session
79
79
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  requirements: []
176
- rubygems_version: 3.6.9
176
+ rubygems_version: 4.0.20
177
177
  specification_version: 4
178
178
  summary: Classy web-development dressed in a DSL
179
179
  test_files: []