rack-www_form_encoding 1.0.1 → 1.0.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: dba3d3bdecb2f0413e0d0392211d8e38cc05f1f0
4
- data.tar.gz: 6e98a542f19f3c0896f1a0992ba51130cfc21f85
3
+ metadata.gz: ec96895f42073bef7afea330e0a9bb2ba719db21
4
+ data.tar.gz: 6482f6061c259549fafa7dc416fe8d2441b454f3
5
5
  SHA512:
6
- metadata.gz: 1e65f6b28418f9c557c8f16e3c31d289991cdf69986ed936a2aea0c9836407dadb9504230a15dfd06f496a514cb397ee54da0ee16bd176892d9ec63c147278aa
7
- data.tar.gz: 4a6ff59051638a9768052fa7c044b5c481f00fb18081171a04a396e9e0326663bcdd2b922d2e63e402e163c2db568eb16aeee3ad16e7d60a469b71874d2e79a7
6
+ metadata.gz: 6dd45715ac0f055fe1d005ab6c6062acea2154804685894668be4bbf5aa0651ca5b83e455ec7d2085ad589143819473a31da55f2c5f47e43f2204e664f476545
7
+ data.tar.gz: 492b0ebf671abf4f30df356623b05b2e160e75d9c026025ab6076d25ab5f65629aa9c1d06f9216ba4980a4d3509e403e97ffe99e923a1bae4e6ea39b74224623
@@ -11,8 +11,11 @@ module Rack
11
11
 
12
12
  def call(env)
13
13
  post_body = env['rack.input'].read
14
- converted = convert_form(post_body, @encoding)
15
- env['rack.input'] = StringIO.new(converted)
14
+
15
+ unless env['CONTENT_TYPE'] && env['CONTENT_TYPE'].start_with?("multipart/form-data;")
16
+ converted = convert_form(post_body, @encoding)
17
+ env['rack.input'] = StringIO.new(converted)
18
+ end
16
19
 
17
20
  env['QUERY_STRING'] = convert_form(env['QUERY_STRING'], @encoding)
18
21
 
@@ -22,10 +25,12 @@ module Rack
22
25
  private
23
26
 
24
27
  def convert_form(params_string, encoding)
25
- return unless params_string
28
+ return params_string unless params_string
26
29
  params = URI.decode_www_form(params_string, @encoding)
27
30
  params.map!{|k,v| [k, encode(v)] }
28
31
  URI.encode_www_form(params)
32
+ rescue ArgumentError => e # the input of decode_www_form must be ASCII only string
33
+ params_string
29
34
  end
30
35
 
31
36
  def encode(string)
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class WWWFormEncoding
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 1.10"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "minitest"
32
+ spec.add_development_dependency "rack-test"
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-www_form_encoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - HORII Keima
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Encode from not UTF-8 www-form-urlencoded params to UTF-8 www-form-urlencoded
70
84
  params
71
85
  email: