rack-utf8_sanitizer 1.10.1 → 1.11.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 +4 -4
- data/.github/workflows/ci.yml +20 -3
- data/CHANGELOG.md +116 -1
- data/README.md +6 -2
- data/lib/rack/utf8_sanitizer.rb +3 -1
- data/rack-utf8_sanitizer.gemspec +1 -1
- data/test/test_utf8_sanitizer.rb +6 -0
- metadata +3 -7
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14d5b3232eb52814e46f5960b435851d0b0a6bdd6d18cfb1220adc08c5ecdb1e
|
|
4
|
+
data.tar.gz: 40d9329c056a74dd0328ac7af2fa4183799cb451cd1795630f6754f24718324a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11ffb7389bcbe67ef49ce1d29829de920d72c44799c623924dd0b93e578d89414de07bb4ef315d50d13e5463825b1d4727f999c10faafb1d507e52875caa09be
|
|
7
|
+
data.tar.gz: 4b9115c9909dc1cfd8378451f0974808f5d834bd7daaaca012d04413e48ed80cc5f8bcb10f6307300b982cf5f56080dafada5963126b5563df18ff83772dcfd8
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,15 +5,32 @@ on: [push, pull_request]
|
|
|
5
5
|
jobs:
|
|
6
6
|
test:
|
|
7
7
|
|
|
8
|
-
runs-on:
|
|
8
|
+
runs-on: ${{ matrix.os }}
|
|
9
9
|
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
|
-
|
|
13
|
+
os: [ubuntu-latest]
|
|
14
|
+
ruby:
|
|
15
|
+
- 2.5
|
|
16
|
+
- 2.6
|
|
17
|
+
- 2.7
|
|
18
|
+
- "3.0"
|
|
19
|
+
- 3.1
|
|
20
|
+
- 3.2
|
|
21
|
+
- 3.3
|
|
22
|
+
- 3.4
|
|
23
|
+
- ruby-head
|
|
24
|
+
- jruby-9.3
|
|
25
|
+
- jruby-9.4
|
|
26
|
+
- jruby-10.0
|
|
27
|
+
- jruby-head
|
|
28
|
+
include:
|
|
29
|
+
- os: ubuntu-22.04
|
|
30
|
+
ruby: jruby-9.2
|
|
14
31
|
|
|
15
32
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
33
|
+
- uses: actions/checkout@v6
|
|
17
34
|
- name: Set up Ruby
|
|
18
35
|
uses: ruby/setup-ruby@v1
|
|
19
36
|
with:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,119 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
v1.11.0 (2025-12-04)
|
|
5
|
+
-------------------------
|
|
6
|
+
|
|
7
|
+
Bugs fixed:
|
|
8
|
+
|
|
9
|
+
* Return HTTP 400 when Content-Length is too large (Benjamin Quorning, #103)
|
|
10
|
+
|
|
11
|
+
v1.10.1 (2025-01-10)
|
|
12
|
+
-------------------------
|
|
13
|
+
|
|
14
|
+
Bugs fixed:
|
|
15
|
+
|
|
16
|
+
* Fix `URI::RFC2396_PARSER` issue with older Rubies (Tekin Süleyman, #94)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
v1.10.0 (2025-01-08)
|
|
20
|
+
-------------------------
|
|
21
|
+
|
|
22
|
+
Changes:
|
|
23
|
+
|
|
24
|
+
* Require Ruby 2.3.0+. (Jean Boussier, #80)
|
|
25
|
+
|
|
26
|
+
Bugs fixed:
|
|
27
|
+
|
|
28
|
+
* Skip sanitizing the request body if the charset is non-utf-8 (#84)
|
|
29
|
+
* Don't use a mutable constant as Rack response (Jean Boussier, #86)
|
|
30
|
+
|
|
31
|
+
Chores:
|
|
32
|
+
|
|
33
|
+
* Add the `frozen_string_literal` header (Benjamin Quorning, #90)
|
|
34
|
+
* Avoid deprecation warming by switching from `URI::DEFAULT_PARSER` to `URI::RFC2396_PARSER` (Roman Gaufman, #92)
|
|
35
|
+
|
|
36
|
+
Performance:
|
|
37
|
+
|
|
38
|
+
* Use Content-Length to read the request body if available (Jean Boussier, #80)
|
|
39
|
+
* Avoid 2nd degree polynomial regexp for sanitizing content type (Jean Boussier, #82)
|
|
40
|
+
* Use `Regexp#match?` over `String#=~` when testing for null bytes (Geoff Harcourt, #85)
|
|
41
|
+
|
|
42
|
+
v1.9.1 (2023-08-31)
|
|
43
|
+
-------------------------
|
|
44
|
+
|
|
45
|
+
Bugs fixed:
|
|
46
|
+
|
|
47
|
+
* Fix null byte sanitisation (Szymon Madeja, #78)
|
|
48
|
+
|
|
49
|
+
v1.9.0 (2023-07-06)
|
|
50
|
+
-------------------------
|
|
51
|
+
|
|
52
|
+
* Optionally sanitize null bytes (James Coleman, #75)
|
|
53
|
+
* CI: add Ruby 3.2 (Peter Goldstein, #71)
|
|
54
|
+
|
|
55
|
+
v1.8.0 (2022-10-25)
|
|
56
|
+
-------------------------
|
|
57
|
+
|
|
58
|
+
Bugs fixed:
|
|
59
|
+
|
|
60
|
+
* Handle EOFError (Kir Shatrov, #57)
|
|
61
|
+
|
|
62
|
+
Features implemented:
|
|
63
|
+
|
|
64
|
+
* Allow Rack version 3 (Alexander Popov, #66)
|
|
65
|
+
* Various CI chores (Olle Jonsson)
|
|
66
|
+
* Move to GitHub Actions, configure Dependabot (Peter Goldstein, #62, #64)
|
|
67
|
+
|
|
68
|
+
v1.7.0 (2020-05-05)
|
|
69
|
+
-------------------------
|
|
70
|
+
|
|
71
|
+
* Resolve Ruby warnings about `URI.escape` (Alexander Popov, #53)
|
|
72
|
+
* README: better reflect that this also can sanitize text bodies (Zach McCormick, #47)
|
|
73
|
+
* Update documentation on exception strategy handler (Josh Frankel, #52)
|
|
74
|
+
|
|
75
|
+
v1.6.0 (2018-06-06)
|
|
76
|
+
-------------------------
|
|
77
|
+
|
|
78
|
+
Bugs fixed:
|
|
79
|
+
|
|
80
|
+
* Add sanitation of cookie header (John Hager, #45)
|
|
81
|
+
|
|
82
|
+
v1.5.0 (2018-02-16)
|
|
83
|
+
-------------------------
|
|
84
|
+
|
|
85
|
+
Bugs fixed:
|
|
86
|
+
|
|
87
|
+
* Sanitize `nil` in `sanitize_uri_encoded_string` (David Čepelík, #44)
|
|
88
|
+
|
|
89
|
+
Features implemented:
|
|
90
|
+
|
|
91
|
+
* Add `:only` and `:except` options (John Hager, #43)
|
|
92
|
+
* Add strategies to rack-utf8_sanitizer (John Hager, #41)
|
|
93
|
+
|
|
94
|
+
```rb
|
|
95
|
+
# Example usage in Rails config/application.rb:
|
|
96
|
+
config.middleware.insert(0, Rack::UTF8Sanitizer, strategy: :exception)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
v1.4.0 (2016-03-07)
|
|
100
|
+
-------------------------
|
|
101
|
+
|
|
102
|
+
Performance:
|
|
103
|
+
|
|
104
|
+
* Use more performant `%char` decoding `.hex.chr` (Martin Emde, #36)
|
|
105
|
+
* Make `HTTP_` a constant to avoid creating the string every loop (Martin Emde, #35)
|
|
106
|
+
|
|
107
|
+
Features implemented:
|
|
108
|
+
|
|
109
|
+
* Add SERVER_NAME to list of sanitization (Denis Lysenko, 9644371)
|
|
110
|
+
|
|
111
|
+
Chores:
|
|
112
|
+
|
|
113
|
+
* Add license to gemspec (Robert Reiz, #38)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
v1.3.2 (2015-12-23)
|
|
5
117
|
-------------------------
|
|
6
118
|
|
|
7
119
|
API modifications:
|
|
@@ -10,6 +122,9 @@ Features implemented:
|
|
|
10
122
|
|
|
11
123
|
Bugs fixed:
|
|
12
124
|
|
|
125
|
+
* Strip UTF-8 Byte Order Mark from the request body (Jean Boussier, #29)
|
|
126
|
+
* Add options to #initialize to allow configurable sanitizable content types (Shelby Switzer, #30)
|
|
127
|
+
|
|
13
128
|
v1.3.1 (2015-07-09)
|
|
14
129
|
-------------------------
|
|
15
130
|
|
data/README.md
CHANGED
|
@@ -52,11 +52,15 @@ The default content types to be sanitized are 'text/plain', 'application/x-www-f
|
|
|
52
52
|
|
|
53
53
|
To add sanitizable content types to the list of defaults, pass the `additional_content_types` options when using Rack::UTF8Sanitizer, e.g.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
``` ruby
|
|
56
|
+
config.middleware.insert 0, Rack::UTF8Sanitizer, additional_content_types: ['application/vnd.api+json']
|
|
57
|
+
```
|
|
56
58
|
|
|
57
59
|
To explicitly set sanitizable content types and override the defaults, use the `sanitizable_content_types` option:
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
``` ruby
|
|
62
|
+
config.middleware.insert 0, Rack::UTF8Sanitizer, sanitizable_content_types: ['application/vnd.api+json']
|
|
63
|
+
```
|
|
60
64
|
|
|
61
65
|
### Whitelist/Blacklist Rack Env Keys
|
|
62
66
|
|
data/lib/rack/utf8_sanitizer.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Rack
|
|
|
10
10
|
StringIO = ::StringIO
|
|
11
11
|
NULL_BYTE_REGEX = /\x00/.freeze
|
|
12
12
|
|
|
13
|
+
class InvalidStream < IOError; end
|
|
13
14
|
class NullByteInString < StandardError; end
|
|
14
15
|
|
|
15
16
|
# options[:sanitizable_content_types] Array
|
|
@@ -27,7 +28,7 @@ module Rack
|
|
|
27
28
|
def call(env)
|
|
28
29
|
begin
|
|
29
30
|
env = sanitize(env)
|
|
30
|
-
rescue EOFError
|
|
31
|
+
rescue EOFError, InvalidStream
|
|
31
32
|
return [400, { "Content-Type" => "text/plain" }, ["Bad Request"]]
|
|
32
33
|
end
|
|
33
34
|
@app.call(env)
|
|
@@ -174,6 +175,7 @@ module Rack
|
|
|
174
175
|
else
|
|
175
176
|
io.read
|
|
176
177
|
end
|
|
178
|
+
raise InvalidStream if input.nil?
|
|
177
179
|
sanitized_input = sanitize_string(strip_byte_order_mark(input))
|
|
178
180
|
if uri_encoded
|
|
179
181
|
sanitized_input = sanitize_uri_encoded_string(sanitized_input).
|
data/rack-utf8_sanitizer.gemspec
CHANGED
data/test/test_utf8_sanitizer.rb
CHANGED
|
@@ -245,6 +245,12 @@ describe Rack::UTF8Sanitizer do
|
|
|
245
245
|
response_env[1]["Set-Cookie"].should == nil
|
|
246
246
|
end
|
|
247
247
|
|
|
248
|
+
it "returns HTTP 400 if CONTENT_LENGTH is larger than actual length of rack.input" do
|
|
249
|
+
@rack_input = StringIO.new("")
|
|
250
|
+
response_env = @app.(request_env.merge("CONTENT_LENGTH" => (@rack_input.length + 1).to_s))
|
|
251
|
+
response_env.should == [400, {"Content-Type"=>"text/plain"}, ["Bad Request"]]
|
|
252
|
+
end
|
|
253
|
+
|
|
248
254
|
it "sanitizes StringIO rack.input" do
|
|
249
255
|
input = "foo=bla&quux=bar"
|
|
250
256
|
@rack_input = StringIO.new input
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rack-utf8_sanitizer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Catherine
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rack
|
|
@@ -84,7 +83,6 @@ files:
|
|
|
84
83
|
- ".github/dependabot.yml"
|
|
85
84
|
- ".github/workflows/ci.yml"
|
|
86
85
|
- ".gitignore"
|
|
87
|
-
- ".travis.yml"
|
|
88
86
|
- CHANGELOG.md
|
|
89
87
|
- Gemfile
|
|
90
88
|
- LICENSE.txt
|
|
@@ -97,7 +95,6 @@ homepage: https://github.com/whitequark/rack-utf8_sanitizer
|
|
|
97
95
|
licenses:
|
|
98
96
|
- MIT
|
|
99
97
|
metadata: {}
|
|
100
|
-
post_install_message:
|
|
101
98
|
rdoc_options: []
|
|
102
99
|
require_paths:
|
|
103
100
|
- lib
|
|
@@ -112,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
109
|
- !ruby/object:Gem::Version
|
|
113
110
|
version: '0'
|
|
114
111
|
requirements: []
|
|
115
|
-
rubygems_version: 3.
|
|
116
|
-
signing_key:
|
|
112
|
+
rubygems_version: 3.6.7
|
|
117
113
|
specification_version: 4
|
|
118
114
|
summary: Rack::UTF8Sanitizer is a Rack middleware which cleans up invalid UTF8 characters
|
|
119
115
|
in request URI and headers.
|