cuba 4.0.1 → 4.0.3

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: 72337c66b56fe3897868fbe795af8c70cb56d2f59078b2b25902760dd59c35c6
4
- data.tar.gz: 18adfb8cdf0f1c05eb73ae51991201bbfae5b581e4c71fe8b0c0126940f79a53
3
+ metadata.gz: fdca6a9e01b7f7981cd430ed976c9d0822739895340549150e4d719196e059c0
4
+ data.tar.gz: 206b7ea5088509c073f6d69f9c72e07c066b0b043483d1ecd2b292e5a9dd9f2e
5
5
  SHA512:
6
- metadata.gz: 28823a910b61fe95f1c195dc2647d170746b1e44176a5a44448b7cc7ffda34b311d3731eb8536faf144a6955e3580c410b6cc12f4e8b648d0f281cdf6c999d73
7
- data.tar.gz: 62ccc633e87fb4695b9a0256ded29111554afd2b658cbae314d0a10f4ff2afb20fb1c06adee2d062d4a0929fa667644d6ed9ed969ea01d2d1861d0ad1372c7fc
6
+ metadata.gz: 36cd6bcfa37d6ab1c50b4235243143117be5de74cfa3d7a065c4434c2c4fd1bd064fd46df2f13d4578427d61c6ceda769566bd26152214787a7357779780f6f5
7
+ data.tar.gz: 64e6ce940c7f8004b88535cb6b8c938da8e0be6ccce33e544843fd97029bccb7763f9ded60860d2299c5632bc825cd7d688585ad37e7449bf42183cbc232f183
data/CHANGELOG CHANGED
@@ -1,10 +1,14 @@
1
+ 4.0.3
2
+
3
+ * Change secure headers to lowercase.
4
+
1
5
  3.9.0
2
6
 
3
- * Cache regular expressions
7
+ * Cache regular expressions.
4
8
 
5
9
  3.8.1
6
10
 
7
- * Remove requirement on Time
11
+ * Remove requirement on Time.
8
12
 
9
13
  3.8.0
10
14
 
@@ -64,4 +68,4 @@
64
68
  * Remove Cuba::VERSION.
65
69
  * Rename _call to call! (inspired from Sinatra).
66
70
  * Fix a memory leak with the caching used in Tilt.
67
- * Adding syntax highlighting to the README Code blocks
71
+ * Adding syntax highlighting to the README Code blocks.
data/cuba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cuba"
3
- s.version = "4.0.1"
3
+ s.version = "4.0.3"
4
4
  s.summary = "Microframework for web applications."
5
5
  s.description = "Cuba is a microframework for web applications."
6
6
  s.authors = ["Michel Martens"]
data/lib/cuba/render.rb CHANGED
@@ -13,7 +13,7 @@ class Cuba
13
13
  end
14
14
 
15
15
  def render(template, locals = {}, layout = settings[:render][:layout])
16
- res.headers["Content-Type"] ||= "text/html; charset=utf-8"
16
+ res.headers[Rack::CONTENT_TYPE] ||= "text/html; charset=utf-8"
17
17
  res.write(view(template, locals, layout))
18
18
  end
19
19
 
@@ -10,6 +10,8 @@
10
10
  # - X-Download-Options [6].
11
11
  # - X-Permitted-Cross-Domain-Policies [7].
12
12
  #
13
+ # Due to HTTP/2 specifications and Rack specifications, field names are applied in all lowercase.
14
+ #
13
15
  # == References
14
16
  #
15
17
  # [1]: https://github.com/twitter/secureheaders
@@ -19,17 +21,18 @@
19
21
  # [5]: http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx
20
22
  # [6]: http://msdn.microsoft.com/en-us/library/ie/jj542450(v=vs.85).aspx
21
23
  # [7]: https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
24
+ # [8]: https://datatracker.ietf.org/doc/html/rfc9113#name-http-fields
22
25
  #
23
26
  class Cuba
24
27
  module Safe
25
28
  module SecureHeaders
26
29
  HEADERS = {
27
- "X-Content-Type-Options" => "nosniff",
28
- "X-Download-Options" => "noopen",
29
- "X-Frame-Options" => "SAMEORIGIN",
30
- "X-Permitted-Cross-Domain-Policies" => "none",
31
- "X-XSS-Protection" => "1; mode=block",
32
- "Strict-Transport-Security" => "max-age=2628000"
30
+ "x-content-type-options" => "nosniff",
31
+ "x-download-options" => "noopen",
32
+ "x-frame-options" => "SAMEORIGIN",
33
+ "x-permitted-cross-domain-policies" => "none",
34
+ "x-xss-protection" => "1; mode=block",
35
+ "strict-transport-security" => "max-age=2628000"
33
36
  }
34
37
 
35
38
  def self.setup(app)
data/lib/cuba.rb CHANGED
@@ -10,7 +10,7 @@ class Cuba
10
10
  REGEXES = Hash.new { |h, pattern| h[pattern] = /\A\/(#{pattern})(\/|\z)/ }
11
11
 
12
12
  class Response
13
- LOCATION = "Location".freeze
13
+ LOCATION = "location".freeze
14
14
 
15
15
  module ContentType
16
16
  HTML = "text/html".freeze # :nodoc:
@@ -91,8 +91,8 @@ class Cuba
91
91
  @app ||= Rack::Builder.new
92
92
  end
93
93
 
94
- def self.use(middleware, *args, &block)
95
- app.use(middleware, *args, &block)
94
+ def self.use(middleware, *args, **kwargs, &block)
95
+ app.use(middleware, *args, **kwargs, &block)
96
96
  end
97
97
 
98
98
  def self.define(&block)
data/test/middleware.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
2
 
3
3
  class Shrimp
4
- def initialize(app)
4
+ def initialize(app, foo:)
5
5
  @app = app
6
+ @foo = foo
6
7
  end
7
8
 
8
9
  def call(env)
@@ -17,7 +18,7 @@ end
17
18
 
18
19
  test do
19
20
  class API < Cuba
20
- use Shrimp
21
+ use Shrimp, foo: 'bar'
21
22
 
22
23
  define do
23
24
  on "v1/test" do
data/test/redirect.rb CHANGED
@@ -16,6 +16,6 @@ test "redirect" do
16
16
  status, headers, body = Cuba.call(env)
17
17
 
18
18
  assert_equal status, 302
19
- assert_equal headers, { "Location" => "/hello" }
19
+ assert_equal headers, { "location" => "/hello" }
20
20
  assert_response body, []
21
21
  end
data/test/render.rb CHANGED
@@ -124,5 +124,5 @@ test "ensures content-type header is set" do
124
124
 
125
125
  _, headers, _ = Cuba.call({})
126
126
 
127
- assert_equal("text/html; charset=utf-8", headers["Content-Type"])
127
+ assert_equal("text/html; charset=utf-8", headers["content-type"])
128
128
  end
data/test/run.rb CHANGED
@@ -17,7 +17,7 @@ test "redirect canonical example" do
17
17
 
18
18
  status, headers, resp = Cuba.call(env)
19
19
 
20
- assert_equal "/login", headers["Location"]
20
+ assert_equal "/login", headers["location"]
21
21
  assert_equal 307, status
22
22
  assert_response resp, []
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuba
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-19 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack