rack-encoding_guard 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -12
- data/VERSION +1 -1
- data/lib/rack/encoding_guard/middleware.rb +1 -1
- data/lib/rack/encoding_guard/reject_strategy.rb +1 -1
- data/rack-encoding_guard.gemspec +2 -2
- data/spec/lib/rack/encoding_guard/middleware_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03cfd562d474ea8ca8fed6d4ddc49041ea547d8
|
4
|
+
data.tar.gz: b5c9080c796145afc48fe9b63e856717444eb1f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91702c42498856445e047d50a97d3a65b1660688eb130e7e67ef8f5f105ee8fd4e4e0d48daee3581e9f3b3d413b561224af8269593ade2ae6faca22e01853487
|
7
|
+
data.tar.gz: 72de23f3b9f462fe5369e32e5318114d6184fe15fc485f41486d4501dae2e712a84826854a171dcc4a4e215287cf2a45ec256ce5292d6bbe171f18d76549d9df
|
data/README.md
CHANGED
@@ -27,28 +27,36 @@ If you are on Rails, you can insert the middleware to your application.rb
|
|
27
27
|
config.middleware.use 'Rack::EncodingGuard::Middleware'
|
28
28
|
```
|
29
29
|
|
30
|
-
###
|
31
|
-
|
30
|
+
### Sanitize Strategy
|
31
|
+
This is the default strategy. When using it sanitization, all invalid characters
|
32
|
+
will be stripped out of all relevant ENV vars. Subsequently, no encoding errors
|
33
|
+
will occur down the middleware stack.
|
32
34
|
```ruby
|
33
|
-
config.middleware.use 'Rack::EncodingGuard::Middleware', :
|
35
|
+
config.middleware.use 'Rack::EncodingGuard::Middleware', :sanitize
|
34
36
|
```
|
35
37
|
|
36
|
-
###
|
37
|
-
When using
|
38
|
+
### Reject Strategy
|
39
|
+
When using this strategy, all requests containing invalid characters are
|
40
|
+
rejected with a HTTP status 400 code ("Bad Request"). Additionally, you can
|
41
|
+
configure which hint will be displayed to the requesting user:
|
38
42
|
```ruby
|
39
|
-
config.middleware.use 'Rack::EncodingGuard::Middleware', :
|
43
|
+
config.middleware.use 'Rack::EncodingGuard::Middleware', :reject, with: 'Check that URL, mate!'
|
40
44
|
```
|
41
45
|
|
42
46
|
## Contributing to Rack::EncodingGuard
|
43
|
-
* Check out the latest master to make sure the feature hasn't been implemented
|
44
|
-
|
47
|
+
* Check out the latest master to make sure the feature hasn't been implemented
|
48
|
+
or the bug hasn't been fixed yet.
|
49
|
+
* Check out the issue tracker to make sure someone already hasn't requested it
|
50
|
+
and/or contributed it.
|
45
51
|
* Fork the project.
|
46
52
|
* Start a feature/bugfix branch.
|
47
53
|
* Commit and push until you are happy with your contribution.
|
48
|
-
* Make sure to add tests for it. This is important so I don't break it in a
|
49
|
-
|
54
|
+
* Make sure to add tests for it. This is important so I don't break it in a
|
55
|
+
future version unintentionally.
|
56
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to
|
57
|
+
have your own version, or is otherwise necessary, that is fine, but please
|
58
|
+
isolate to its own commit so I can cherry-pick around it.
|
50
59
|
|
51
60
|
## Copyright
|
52
|
-
Copyright (c) 2015 Tobias Casper. See LICENSE.txt for
|
53
|
-
further details.
|
61
|
+
Copyright (c) 2015 Tobias Casper. See LICENSE.txt for further details.
|
54
62
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -18,7 +18,7 @@ module Rack
|
|
18
18
|
|
19
19
|
def resolve_strategy_object(strategy, options)
|
20
20
|
case strategy
|
21
|
-
when nil then
|
21
|
+
when nil then SanitizeStrategy.new(options)
|
22
22
|
when Class then strategy.new(options)
|
23
23
|
when String then strategy.constantize.new(options)
|
24
24
|
when Symbol
|
data/rack-encoding_guard.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rack-encoding_guard 0.1.
|
5
|
+
# stub: rack-encoding_guard 0.1.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rack-encoding_guard"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -13,14 +13,14 @@ describe Rack::EncodingGuard::Middleware do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with strategies' do
|
16
|
-
it 'uses
|
16
|
+
it 'uses SanitizeStrategy when second argument is omitted' do
|
17
17
|
middleware = described_class.new(app)
|
18
|
-
expect(middleware.strategy).to be_a Rack::EncodingGuard::
|
18
|
+
expect(middleware.strategy).to be_a Rack::EncodingGuard::SanitizeStrategy
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'uses
|
21
|
+
it 'uses SanitizeStrategy when second argument is nil' do
|
22
22
|
middleware = described_class.new(app, nil)
|
23
|
-
expect(middleware.strategy).to be_a Rack::EncodingGuard::
|
23
|
+
expect(middleware.strategy).to be_a Rack::EncodingGuard::SanitizeStrategy
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'uses RejectStrategy when second argument is :reject' do
|