grac 2.2.1 → 2.2.2

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
  SHA1:
3
- metadata.gz: 7621f7f0d1f762778360d4af46adc60db2249ecd
4
- data.tar.gz: 78f36c90b9f84c9d85ad1f068eab915977931da5
3
+ metadata.gz: 280ed2bb063aec54e36cdbae1273eed77bf6d7a8
4
+ data.tar.gz: a3f5f241c7b34fe9f1bb22de72b15b199038def1
5
5
  SHA512:
6
- metadata.gz: 174a6b9e62567a77101e2d874495cfd2edf37450f08b5095a54410f03b248efa369d24d3881e406ef9c58477455c25bcca11d6fe65097b37e4dd87e883b9ba9a
7
- data.tar.gz: e3ba0c9ac7d580bbbe86e373b6f23ea3f790e49e0cb27997b3b631d02a2eef488f0fde06e3b5b3340273dd1c12acf632b0e8abb614034540abe23610bcdf75db
6
+ metadata.gz: 00fac6601b78e14c03f9f6e12010675187d664d59c46e928ac84dee53b65a4cc66f03c526b9c1ecd89976b95fc39d76ded2f35faab1c4fd0b050c717ee64e884
7
+ data.tar.gz: 36cc32054886343c9d792eab5b7b24aeeb3a7c935c703b0742dd6d6317b6bff49ddea6d783a60b5f509bea9f7b35cad1cf1d7378a49baeed8a26b2a47f3d53f1
@@ -1,3 +1,4 @@
1
+ require 'cgi'
1
2
  require 'json'
2
3
  require 'typhoeus'
3
4
  require 'uri'
@@ -42,7 +43,7 @@ module Grac
42
43
 
43
44
  def path(path, variables = {})
44
45
  variables.each do |key, value|
45
- path = path.gsub("{#{key}}", value)
46
+ path = path.gsub("{#{key}}", escape_url_param(value))
46
47
  end
47
48
  self.class.new("#{@uri}#{path}", @options)
48
49
  end
@@ -64,7 +65,7 @@ module Grac
64
65
  def call(opts, request_uri, method, params, body)
65
66
  request_hash = {
66
67
  :method => method,
67
- :params => params,
68
+ :params => params, # Query params are escaped by Typhoeus
68
69
  :body => body,
69
70
  :connecttimeout => opts[:connecttimeout],
70
71
  :timeout => opts[:timeout],
@@ -162,5 +163,14 @@ module Grac
162
163
 
163
164
  return data
164
165
  end
166
+
167
+ def escape_url_param(value)
168
+ # We don't want spaces to be encoded as plus sign - a plus sign can be ambiguous in a URL and
169
+ # either represent a plus sign or a space.
170
+ # CGI::escape replaces all plus signs with their percent-encoding representation, so all
171
+ # remaining plus signs are spaces. Replacing these with a space's percent encoding makes the
172
+ # encoding unambiguous.
173
+ CGI::escape(value).gsub('+', '%20')
174
+ end
165
175
  end
166
176
  end
@@ -1,3 +1,3 @@
1
1
  module Grac
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grac
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.2.2
129
+ rubygems_version: 2.4.8
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Very generic client for REST API with basic error handling