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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05413b164ca4a261a4b6366d8a44a7ca52f1370a
4
- data.tar.gz: de38cb9bb4f4b741e89b2f5eefebf066d8546602
3
+ metadata.gz: a03cfd562d474ea8ca8fed6d4ddc49041ea547d8
4
+ data.tar.gz: b5c9080c796145afc48fe9b63e856717444eb1f9
5
5
  SHA512:
6
- metadata.gz: 519c56b25550056d23c398d78032529f19e3574b3f59ca028e346432b1b040ddc4e716d2514edd455f16b1cf6daf3c4f77ce74daf2398d96b085b2367b9552c7
7
- data.tar.gz: 2563866e335486605a9ee6e6d73eef371a6c570c4e0a163ff729e3d8001b74e30817b94501185b6c032015aecbf056a69829980834d5f1c514fce45cf491d9fe
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
- ### Reject Strategy
31
- By default, all requests containing characters with invalid encodings are rejected with a HTTP status 400 code ("Bad Request"). Additionally, you can configure which message will be shown to the requesting user in this case:
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', :reject, with: 'Check that URL, mate!'
35
+ config.middleware.use 'Rack::EncodingGuard::Middleware', :sanitize
34
36
  ```
35
37
 
36
- ### Sanitize Strategy
37
- When using the sanitize strategy it is also possible to allow requests containing invalid characters. All invalid characters will be stripped out of all relevant ENV vars so no encoding errors will occur down the middleware stack.
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', :sanitize
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 or the bug hasn't been fixed yet.
44
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
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 future version unintentionally.
49
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
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
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 RejectStrategy.new(options)
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
@@ -16,7 +16,7 @@ module Rack
16
16
 
17
17
  def invalid_request?(env)
18
18
  Strategy::PROCESSIBLE_KEYS.any? do |key|
19
- !env[key].to_s.valid_encoding?
19
+ !env[key].to_s.dup.force_encoding(Encoding::UTF_8).valid_encoding?
20
20
  end
21
21
  end
22
22
 
@@ -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.1 ruby lib
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.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 RejectStrategy when second argument is omitted' do
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::RejectStrategy
18
+ expect(middleware.strategy).to be_a Rack::EncodingGuard::SanitizeStrategy
19
19
  end
20
20
 
21
- it 'uses RejectStrategy when second argument is nil' do
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::RejectStrategy
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-encoding_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Casper