rack 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 942ed8704e37c2a93a99fe47fe5402122dbbacc3
4
- data.tar.gz: 8a52005b33ac3863b001ea56350b65b50c74b8a0
3
+ metadata.gz: 2ace023b19edf8bddd9a3124d7467475ae2b26c8
4
+ data.tar.gz: 83af4a55c057c7c69368aecfb591d9d14fbb39bc
5
5
  SHA512:
6
- metadata.gz: f7a7414780bc2acadb7b8fc479ea7087c1b93ce0a1d82649dccd33caef7d8fe3eaba5f4188fe58baa3b889331ed29ac584b13b11572dc6ec5dc0844f73f9c2fe
7
- data.tar.gz: 6eb24f229ef6aa6db52dfc04d2c519be8a4e89c2010d3c0f1d89a50b4973c7eafd07819c1d0ab961a10ee9e063174c76374b2bb3f1a52865458750a5ef7263b1
6
+ metadata.gz: a87031d7cbbd2fe42850cf3e85715efa780e67a3e536661f1c62fd6492df4126a83b2fc9f380c11383ec6f0d6eb219557a7bb215d3f0de048822e26c81e4d5b7
7
+ data.tar.gz: 07f4041dfa430a62a524ce7e02c66df531d5a29b87e44569706cbdf9cfe499e083232e86d6f519a48755f262cd562a307160b2f89ce6e9ffe339361e12eb59b3
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012 Christian Neukirchen <purl.org/net/chneukirchen>
1
+ Copyright (c) 2007-2015 Christian Neukirchen <purl.org/net/chneukirchen>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
@@ -0,0 +1,348 @@
1
+ ### December 18th, Thirty sixth public release 1.6.0
2
+ - TODO
3
+
4
+ ### February 7th, Thirty fifth public release 1.5.2
5
+ - Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
6
+ - Fix CVE-2013-0262, symlink path traversal in Rack::File
7
+ - Add various methods to Session for enhanced Rails compatibility
8
+ - Request#trusted_proxy? now only matches whole stirngs
9
+ - Add JSON cookie coder, to be default in Rack 1.6+ due to security concerns
10
+ - URLMap host matching in environments that don't set the Host header fixed
11
+ - Fix a race condition that could result in overwritten pidfiles
12
+ - Various documentation additions
13
+
14
+ ### February 7th, Thirty fifth public release 1.4.5
15
+ - Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
16
+ - Fix CVE-2013-0262, symlink path traversal in Rack::File
17
+
18
+ ### February 7th, Thirty fifth public release 1.1.6, 1.2.8, 1.3.10
19
+ - Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
20
+
21
+ ### January 28th, 2013: Thirty fourth public release 1.5.1
22
+ - Rack::Lint check_hijack now conforms to other parts of SPEC
23
+ - Added hash-like methods to Abstract::ID::SessionHash for compatibility
24
+ - Various documentation corrections
25
+
26
+ ### January 21st, 2013: Thirty third public release 1.5.0
27
+ - Introduced hijack SPEC, for before-response and after-response hijacking
28
+ - SessionHash is no longer a Hash subclass
29
+ - Rack::File cache_control parameter is removed, in place of headers options
30
+ - Rack::Auth::AbstractRequest#scheme now yields strings, not symbols
31
+ - Rack::Utils cookie functions now format expires in RFC 2822 format
32
+ - Rack::File now has a default mime type
33
+ - rackup -b 'run Rack::File.new(".")', option provides command line configs
34
+ - Rack::Deflater will no longer double encode bodies
35
+ - Rack::Mime#match? provides convenience for Accept header matching
36
+ - Rack::Utils#q_values provides splitting for Accept headers
37
+ - Rack::Utils#best_q_match provides a helper for Accept headers
38
+ - Rack::Handler.pick provides convenience for finding available servers
39
+ - Puma added to the list of default servers (preferred over Webrick)
40
+ - Various middleware now correctly close body when replacing it
41
+ - Rack::Request#params is no longer persistent with only GET params
42
+ - Rack::Request#update_param and #delete_param provide persistent operations
43
+ - Rack::Request#trusted_proxy? now returns true for local unix sockets
44
+ - Rack::Response no longer forces Content-Types
45
+ - Rack::Sendfile provides local mapping configuration options
46
+ - Rack::Utils#rfc2109 provides old netscape style time output
47
+ - Updated HTTP status codes
48
+ - Ruby 1.8.6 likely no longer passes tests, and is no longer fully supported
49
+
50
+ ### January 13th, 2013: Thirty second public release 1.4.4, 1.3.9, 1.2.7, 1.1.5
51
+ - [SEC] Rack::Auth::AbstractRequest no longer symbolizes arbitrary strings
52
+ - Fixed erroneous test case in the 1.3.x series
53
+
54
+ ### January 7th, 2013: Thirty first public release 1.4.3
55
+ - Security: Prevent unbounded reads in large multipart boundaries
56
+
57
+ ### January 7th, 2013: Thirtieth public release 1.3.8
58
+ - Security: Prevent unbounded reads in large multipart boundaries
59
+
60
+ ### January 6th, 2013: Twenty ninth public release 1.4.2
61
+ - Add warnings when users do not provide a session secret
62
+ - Fix parsing performance for unquoted filenames
63
+ - Updated URI backports
64
+ - Fix URI backport version matching, and silence constant warnings
65
+ - Correct parameter parsing with empty values
66
+ - Correct rackup '-I' flag, to allow multiple uses
67
+ - Correct rackup pidfile handling
68
+ - Report rackup line numbers correctly
69
+ - Fix request loops caused by non-stale nonces with time limits
70
+ - Fix reloader on Windows
71
+ - Prevent infinite recursions from Response#to_ary
72
+ - Various middleware better conforms to the body close specification
73
+ - Updated language for the body close specification
74
+ - Additional notes regarding ECMA escape compatibility issues
75
+ - Fix the parsing of multiple ranges in range headers
76
+ - Prevent errors from empty parameter keys
77
+ - Added PATCH verb to Rack::Request
78
+ - Various documentation updates
79
+ - Fix session merge semantics (fixes rack-test)
80
+ - Rack::Static :index can now handle multiple directories
81
+ - All tests now utilize Rack::Lint (special thanks to Lars Gierth)
82
+ - Rack::File cache_control parameter is now deprecated, and removed by 1.5
83
+ - Correct Rack::Directory script name escaping
84
+ - Rack::Static supports header rules for sophisticated configurations
85
+ - Multipart parsing now works without a Content-Length header
86
+ - New logos courtesy of Zachary Scott!
87
+ - Rack::BodyProxy now explicitly defines #each, useful for C extensions
88
+ - Cookies that are not URI escaped no longer cause exceptions
89
+
90
+ ### January 6th, 2013: Twenty eighth public release 1.3.7
91
+ - Add warnings when users do not provide a session secret
92
+ - Fix parsing performance for unquoted filenames
93
+ - Updated URI backports
94
+ - Fix URI backport version matching, and silence constant warnings
95
+ - Correct parameter parsing with empty values
96
+ - Correct rackup '-I' flag, to allow multiple uses
97
+ - Correct rackup pidfile handling
98
+ - Report rackup line numbers correctly
99
+ - Fix request loops caused by non-stale nonces with time limits
100
+ - Fix reloader on Windows
101
+ - Prevent infinite recursions from Response#to_ary
102
+ - Various middleware better conforms to the body close specification
103
+ - Updated language for the body close specification
104
+ - Additional notes regarding ECMA escape compatibility issues
105
+ - Fix the parsing of multiple ranges in range headers
106
+
107
+ ### January 6th, 2013: Twenty seventh public release 1.2.6
108
+ - Add warnings when users do not provide a session secret
109
+ - Fix parsing performance for unquoted filenames
110
+
111
+ ### January 6th, 2013: Twenty sixth public release 1.1.4
112
+ - Add warnings when users do not provide a session secret
113
+
114
+ ### January 22nd, 2012: Twenty fifth public release 1.4.1
115
+ - Alter the keyspace limit calculations to reduce issues with nested params
116
+ - Add a workaround for multipart parsing where files contain unescaped "%"
117
+ - Added Rack::Response::Helpers#method_not_allowed? (code 405)
118
+ - Rack::File now returns 404 for illegal directory traversals
119
+ - Rack::File now returns 405 for illegal methods (non HEAD/GET)
120
+ - Rack::Cascade now catches 405 by default, as well as 404
121
+ - Cookies missing '--' no longer cause an exception to be raised
122
+ - Various style changes and documentation spelling errors
123
+ - Rack::BodyProxy always ensures to execute its block
124
+ - Additional test coverage around cookies and secrets
125
+ - Rack::Session::Cookie can now be supplied either secret or old_secret
126
+ - Tests are no longer dependent on set order
127
+ - Rack::Static no longer defaults to serving index files
128
+ - Rack.release was fixed
129
+
130
+ ### December 28th, 2011: Twenty fourth public release 1.4.0
131
+ - Ruby 1.8.6 support has officially been dropped. Not all tests pass.
132
+ - Raise sane error messages for broken config.ru
133
+ - Allow combining run and map in a config.ru
134
+ - Rack::ContentType will not set Content-Type for responses without a body
135
+ - Status code 205 does not send a response body
136
+ - Rack::Response::Helpers will not rely on instance variables
137
+ - Rack::Utils.build_query no longer outputs '=' for nil query values
138
+ - Various mime types added
139
+ - Rack::MockRequest now supports HEAD
140
+ - Rack::Directory now supports files that contain RFC3986 reserved chars
141
+ - Rack::File now only supports GET and HEAD requests
142
+ - Rack::Server#start now passes the block to Rack::Handler::<h>#run
143
+ - Rack::Static now supports an index option
144
+ - Added the Teapot status code
145
+ - rackup now defaults to Thin instead of Mongrel (if installed)
146
+ - Support added for HTTP_X_FORWARDED_SCHEME
147
+ - Numerous bug fixes, including many fixes for new and alternate rubies
148
+
149
+ ### December 28th, 2011: Twenty first public release: 1.1.3.
150
+ - Security fix. http://www.ocert.org/advisories/ocert-2011-003.html
151
+ Further information here: http://jruby.org/2011/12/27/jruby-1-6-5-1
152
+
153
+ ### October 17, 2011: Twentieth public release 1.3.5
154
+ - Fix annoying warnings caused by the backport in 1.3.4
155
+
156
+ ### October 1, 2011: Nineteenth public release 1.3.4
157
+ - Backport security fix from 1.9.3, also fixes some roundtrip issues in URI
158
+ - Small documentation update
159
+ - Fix an issue where BodyProxy could cause an infinite recursion
160
+ - Add some supporting files for travis-ci
161
+
162
+ ### September 16, 2011: Eighteenth public release 1.2.4
163
+ - Fix a bug with MRI regex engine to prevent XSS by malformed unicode
164
+
165
+ ### September 16, 2011: Seventeenth public release 1.3.3
166
+ - Fix bug with broken query parameters in Rack::ShowExceptions
167
+ - Rack::Request#cookies no longer swallows exceptions on broken input
168
+ - Prevents XSS attacks enabled by bug in Ruby 1.8's regexp engine
169
+ - Rack::ConditionalGet handles broken If-Modified-Since helpers
170
+
171
+ ### July 16, 2011: Sixteenth public release 1.3.2
172
+ - Fix for Rails and rack-test, Rack::Utils#escape calls to_s
173
+
174
+ ### July 13, 2011: Fifteenth public release 1.3.1
175
+ - Fix 1.9.1 support
176
+ - Fix JRuby support
177
+ - Properly handle $KCODE in Rack::Utils.escape
178
+ - Make method_missing/respond_to behavior consistent for Rack::Lock,
179
+ Rack::Auth::Digest::Request and Rack::Multipart::UploadedFile
180
+ - Reenable passing rack.session to session middleware
181
+ - Rack::CommonLogger handles streaming responses correctly
182
+ - Rack::MockResponse calls close on the body object
183
+ - Fix a DOS vector from MRI stdlib backport
184
+
185
+ ### May 22nd, 2011: Fourteenth public release 1.2.3
186
+ - Pulled in relevant bug fixes from 1.3
187
+ - Fixed 1.8.6 support
188
+
189
+ ### May 22nd, 2011: Thirteenth public release 1.3.0
190
+ - Various performance optimizations
191
+ - Various multipart fixes
192
+ - Various multipart refactors
193
+ - Infinite loop fix for multipart
194
+ - Test coverage for Rack::Server returns
195
+ - Allow files with '..', but not path components that are '..'
196
+ - rackup accepts handler-specific options on the command line
197
+ - Request#params no longer merges POST into GET (but returns the same)
198
+ - Use URI.encode_www_form_component instead. Use core methods for escaping.
199
+ - Allow multi-line comments in the config file
200
+ - Bug L#94 reported by Nikolai Lugovoi, query parameter unescaping.
201
+ - Rack::Response now deletes Content-Length when appropriate
202
+ - Rack::Deflater now supports streaming
203
+ - Improved Rack::Handler loading and searching
204
+ - Support for the PATCH verb
205
+ - env['rack.session.options'] now contains session options
206
+ - Cookies respect renew
207
+ - Session middleware uses SecureRandom.hex
208
+
209
+ ### March 13th, 2011: Twelfth public release 1.2.2/1.1.2.
210
+ - Security fix in Rack::Auth::Digest::MD5: when authenticator
211
+ returned nil, permission was granted on empty password.
212
+
213
+ ### June 15th, 2010: Eleventh public release 1.2.1.
214
+ - Make CGI handler rewindable
215
+ - Rename spec/ to test/ to not conflict with SPEC on lesser
216
+ operating systems
217
+
218
+ ### June 13th, 2010: Tenth public release 1.2.0.
219
+ - Removed Camping adapter: Camping 2.0 supports Rack as-is
220
+ - Removed parsing of quoted values
221
+ - Add Request.trace? and Request.options?
222
+ - Add mime-type for .webm and .htc
223
+ - Fix HTTP_X_FORWARDED_FOR
224
+ - Various multipart fixes
225
+ - Switch test suite to bacon
226
+
227
+ ### January 3rd, 2010: Ninth public release 1.1.0.
228
+ - Moved Auth::OpenID to rack-contrib.
229
+ - SPEC change that relaxes Lint slightly to allow subclasses of the
230
+ required types
231
+ - SPEC change to document rack.input binary mode in greator detail
232
+ - SPEC define optional rack.logger specification
233
+ - File servers support X-Cascade header
234
+ - Imported Config middleware
235
+ - Imported ETag middleware
236
+ - Imported Runtime middleware
237
+ - Imported Sendfile middleware
238
+ - New Logger and NullLogger middlewares
239
+ - Added mime type for .ogv and .manifest.
240
+ - Don't squeeze PATH_INFO slashes
241
+ - Use Content-Type to determine POST params parsing
242
+ - Update Rack::Utils::HTTP_STATUS_CODES hash
243
+ - Add status code lookup utility
244
+ - Response should call #to_i on the status
245
+ - Add Request#user_agent
246
+ - Request#host knows about forwared host
247
+ - Return an empty string for Request#host if HTTP_HOST and
248
+ SERVER_NAME are both missing
249
+ - Allow MockRequest to accept hash params
250
+ - Optimizations to HeaderHash
251
+ - Refactored rackup into Rack::Server
252
+ - Added Utils.build_nested_query to complement Utils.parse_nested_query
253
+ - Added Utils::Multipart.build_multipart to complement
254
+ Utils::Multipart.parse_multipart
255
+ - Extracted set and delete cookie helpers into Utils so they can be
256
+ used outside Response
257
+ - Extract parse_query and parse_multipart in Request so subclasses
258
+ can change their behavior
259
+ - Enforce binary encoding in RewindableInput
260
+ - Set correct external_encoding for handlers that don't use RewindableInput
261
+
262
+ ### October 18th, 2009: Eighth public release 1.0.1.
263
+ - Bump remainder of rack.versions.
264
+ - Support the pure Ruby FCGI implementation.
265
+ - Fix for form names containing "=": split first then unescape components
266
+ - Fixes the handling of the filename parameter with semicolons in names.
267
+ - Add anchor to nested params parsing regexp to prevent stack overflows
268
+ - Use more compatible gzip write api instead of "<<".
269
+ - Make sure that Reloader doesn't break when executed via ruby -e
270
+ - Make sure WEBrick respects the :Host option
271
+ - Many Ruby 1.9 fixes.
272
+
273
+ ### April 25th, 2009: Seventh public release 1.0.0.
274
+ - SPEC change: Rack::VERSION has been pushed to [1,0].
275
+ - SPEC change: header values must be Strings now, split on "\n".
276
+ - SPEC change: Content-Length can be missing, in this case chunked transfer
277
+ encoding is used.
278
+ - SPEC change: rack.input must be rewindable and support reading into
279
+ a buffer, wrap with Rack::RewindableInput if it isn't.
280
+ - SPEC change: rack.session is now specified.
281
+ - SPEC change: Bodies can now additionally respond to #to_path with
282
+ a filename to be served.
283
+ - NOTE: String bodies break in 1.9, use an Array consisting of a
284
+ single String instead.
285
+ - New middleware Rack::Lock.
286
+ - New middleware Rack::ContentType.
287
+ - Rack::Reloader has been rewritten.
288
+ - Major update to Rack::Auth::OpenID.
289
+ - Support for nested parameter parsing in Rack::Response.
290
+ - Support for redirects in Rack::Response.
291
+ - HttpOnly cookie support in Rack::Response.
292
+ - The Rakefile has been rewritten.
293
+ - Many bugfixes and small improvements.
294
+
295
+ ### January 9th, 2009: Sixth public release 0.9.1.
296
+ - Fix directory traversal exploits in Rack::File and Rack::Directory.
297
+
298
+ ### January 6th, 2009: Fifth public release 0.9.
299
+ - Rack is now managed by the Rack Core Team.
300
+ - Rack::Lint is stricter and follows the HTTP RFCs more closely.
301
+ - Added ConditionalGet middleware.
302
+ - Added ContentLength middleware.
303
+ - Added Deflater middleware.
304
+ - Added Head middleware.
305
+ - Added MethodOverride middleware.
306
+ - Rack::Mime now provides popular MIME-types and their extension.
307
+ - Mongrel Header now streams.
308
+ - Added Thin handler.
309
+ - Official support for swiftiplied Mongrel.
310
+ - Secure cookies.
311
+ - Made HeaderHash case-preserving.
312
+ - Many bugfixes and small improvements.
313
+
314
+ ### August 21st, 2008: Fourth public release 0.4.
315
+ - New middleware, Rack::Deflater, by Christoffer Sawicki.
316
+ - OpenID authentication now needs ruby-openid 2.
317
+ - New Memcache sessions, by blink.
318
+ - Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
319
+ - Rack::Reloader is not loaded in rackup development mode.
320
+ - rackup can daemonize with -D.
321
+ - Many bugfixes, especially for pool sessions, URLMap, thread safety
322
+ and tempfile handling.
323
+ - Improved tests.
324
+ - Rack moved to Git.
325
+
326
+ ### February 26th, 2008: Third public release 0.3.
327
+ - LiteSpeed handler, by Adrian Madrid.
328
+ - SCGI handler, by Jeremy Evans.
329
+ - Pool sessions, by blink.
330
+ - OpenID authentication, by blink.
331
+ - :Port and :File options for opening FastCGI sockets, by blink.
332
+ - Last-Modified HTTP header for Rack::File, by blink.
333
+ - Rack::Builder#use now accepts blocks, by Corey Jewett.
334
+ (See example/protectedlobster.ru)
335
+ - HTTP status 201 can contain a Content-Type and a body now.
336
+ - Many bugfixes, especially related to Cookie handling.
337
+
338
+ ### May 16th, 2007: Second public release 0.2.
339
+ - HTTP Basic authentication.
340
+ - Cookie Sessions.
341
+ - Static file handler.
342
+ - Improved Rack::Request.
343
+ - Improved Rack::Response.
344
+ - Added Rack::ShowStatus, for better default error messages.
345
+ - Bug fixes in the Camping adapter.
346
+ - Removed Rails adapter, was too alpha.
347
+
348
+ ### March 3rd, 2007: First public release 0.1.
@@ -94,7 +94,7 @@ The plethora of useful middleware created the need for a project that
94
94
  collects fresh Rack middleware. rack-contrib includes a variety of
95
95
  add-on components for Rack and it is easy to contribute new modules.
96
96
 
97
- * http://github.com/rack/rack-contrib
97
+ * https://github.com/rack/rack-contrib
98
98
 
99
99
  == rackup
100
100
 
@@ -183,13 +183,11 @@ run on port 11211) and memcache-client installed.
183
183
 
184
184
  == Configuration
185
185
 
186
- Several parameters can be modified on `Rack::Utils` to configure Rack behaviour.
186
+ Several parameters can be modified on Rack::Utils to configure Rack behaviour.
187
187
 
188
188
  e.g:
189
189
 
190
- ```ruby
191
- Rack::Utils.key_space_limit = 128
192
- ```
190
+ Rack::Utils.key_space_limit = 128
193
191
 
194
192
  === key_space_limit
195
193
 
@@ -203,364 +201,20 @@ Default to 65536 characters (4 kiB in worst case).
203
201
  The maximum number of parts a request can contain.
204
202
  Accepting too many part can lead to the server running out of file handles.
205
203
 
206
- The default is `128`, which mean that a single request can't upload more than 128 files at once.
204
+ The default is 128, which means that a single request can't upload more than 128 files at once.
207
205
 
208
- Set to `0` for not limit.
206
+ Set to 0 for no limit.
209
207
 
210
- Can also be set via the `RACK_MULTIPART_PART_LIMIT` environment variable.
208
+ Can also be set via the RACK_MULTIPART_PART_LIMIT environment variable.
211
209
 
212
210
  == History
213
211
 
214
- * March 3rd, 2007: First public release 0.1.
215
-
216
- * May 16th, 2007: Second public release 0.2.
217
- * HTTP Basic authentication.
218
- * Cookie Sessions.
219
- * Static file handler.
220
- * Improved Rack::Request.
221
- * Improved Rack::Response.
222
- * Added Rack::ShowStatus, for better default error messages.
223
- * Bug fixes in the Camping adapter.
224
- * Removed Rails adapter, was too alpha.
225
-
226
- * February 26th, 2008: Third public release 0.3.
227
- * LiteSpeed handler, by Adrian Madrid.
228
- * SCGI handler, by Jeremy Evans.
229
- * Pool sessions, by blink.
230
- * OpenID authentication, by blink.
231
- * :Port and :File options for opening FastCGI sockets, by blink.
232
- * Last-Modified HTTP header for Rack::File, by blink.
233
- * Rack::Builder#use now accepts blocks, by Corey Jewett.
234
- (See example/protectedlobster.ru)
235
- * HTTP status 201 can contain a Content-Type and a body now.
236
- * Many bugfixes, especially related to Cookie handling.
237
-
238
- * August 21st, 2008: Fourth public release 0.4.
239
- * New middleware, Rack::Deflater, by Christoffer Sawicki.
240
- * OpenID authentication now needs ruby-openid 2.
241
- * New Memcache sessions, by blink.
242
- * Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
243
- * Rack::Reloader is not loaded in rackup development mode.
244
- * rackup can daemonize with -D.
245
- * Many bugfixes, especially for pool sessions, URLMap, thread safety
246
- and tempfile handling.
247
- * Improved tests.
248
- * Rack moved to Git.
249
-
250
- * January 6th, 2009: Fifth public release 0.9.
251
- * Rack is now managed by the Rack Core Team.
252
- * Rack::Lint is stricter and follows the HTTP RFCs more closely.
253
- * Added ConditionalGet middleware.
254
- * Added ContentLength middleware.
255
- * Added Deflater middleware.
256
- * Added Head middleware.
257
- * Added MethodOverride middleware.
258
- * Rack::Mime now provides popular MIME-types and their extension.
259
- * Mongrel Header now streams.
260
- * Added Thin handler.
261
- * Official support for swiftiplied Mongrel.
262
- * Secure cookies.
263
- * Made HeaderHash case-preserving.
264
- * Many bugfixes and small improvements.
265
-
266
- * January 9th, 2009: Sixth public release 0.9.1.
267
- * Fix directory traversal exploits in Rack::File and Rack::Directory.
268
-
269
- * April 25th, 2009: Seventh public release 1.0.0.
270
- * SPEC change: Rack::VERSION has been pushed to [1,0].
271
- * SPEC change: header values must be Strings now, split on "\n".
272
- * SPEC change: Content-Length can be missing, in this case chunked transfer
273
- encoding is used.
274
- * SPEC change: rack.input must be rewindable and support reading into
275
- a buffer, wrap with Rack::RewindableInput if it isn't.
276
- * SPEC change: rack.session is now specified.
277
- * SPEC change: Bodies can now additionally respond to #to_path with
278
- a filename to be served.
279
- * NOTE: String bodies break in 1.9, use an Array consisting of a
280
- single String instead.
281
- * New middleware Rack::Lock.
282
- * New middleware Rack::ContentType.
283
- * Rack::Reloader has been rewritten.
284
- * Major update to Rack::Auth::OpenID.
285
- * Support for nested parameter parsing in Rack::Response.
286
- * Support for redirects in Rack::Response.
287
- * HttpOnly cookie support in Rack::Response.
288
- * The Rakefile has been rewritten.
289
- * Many bugfixes and small improvements.
290
-
291
- * October 18th, 2009: Eighth public release 1.0.1.
292
- * Bump remainder of rack.versions.
293
- * Support the pure Ruby FCGI implementation.
294
- * Fix for form names containing "=": split first then unescape components
295
- * Fixes the handling of the filename parameter with semicolons in names.
296
- * Add anchor to nested params parsing regexp to prevent stack overflows
297
- * Use more compatible gzip write api instead of "<<".
298
- * Make sure that Reloader doesn't break when executed via ruby -e
299
- * Make sure WEBrick respects the :Host option
300
- * Many Ruby 1.9 fixes.
301
-
302
- * January 3rd, 2010: Ninth public release 1.1.0.
303
- * Moved Auth::OpenID to rack-contrib.
304
- * SPEC change that relaxes Lint slightly to allow subclasses of the
305
- required types
306
- * SPEC change to document rack.input binary mode in greator detail
307
- * SPEC define optional rack.logger specification
308
- * File servers support X-Cascade header
309
- * Imported Config middleware
310
- * Imported ETag middleware
311
- * Imported Runtime middleware
312
- * Imported Sendfile middleware
313
- * New Logger and NullLogger middlewares
314
- * Added mime type for .ogv and .manifest.
315
- * Don't squeeze PATH_INFO slashes
316
- * Use Content-Type to determine POST params parsing
317
- * Update Rack::Utils::HTTP_STATUS_CODES hash
318
- * Add status code lookup utility
319
- * Response should call #to_i on the status
320
- * Add Request#user_agent
321
- * Request#host knows about forwared host
322
- * Return an empty string for Request#host if HTTP_HOST and
323
- SERVER_NAME are both missing
324
- * Allow MockRequest to accept hash params
325
- * Optimizations to HeaderHash
326
- * Refactored rackup into Rack::Server
327
- * Added Utils.build_nested_query to complement Utils.parse_nested_query
328
- * Added Utils::Multipart.build_multipart to complement
329
- Utils::Multipart.parse_multipart
330
- * Extracted set and delete cookie helpers into Utils so they can be
331
- used outside Response
332
- * Extract parse_query and parse_multipart in Request so subclasses
333
- can change their behavior
334
- * Enforce binary encoding in RewindableInput
335
- * Set correct external_encoding for handlers that don't use RewindableInput
336
-
337
- * June 13th, 2010: Tenth public release 1.2.0.
338
- * Removed Camping adapter: Camping 2.0 supports Rack as-is
339
- * Removed parsing of quoted values
340
- * Add Request.trace? and Request.options?
341
- * Add mime-type for .webm and .htc
342
- * Fix HTTP_X_FORWARDED_FOR
343
- * Various multipart fixes
344
- * Switch test suite to bacon
345
-
346
- * June 15th, 2010: Eleventh public release 1.2.1.
347
- * Make CGI handler rewindable
348
- * Rename spec/ to test/ to not conflict with SPEC on lesser
349
- operating systems
350
-
351
- * March 13th, 2011: Twelfth public release 1.2.2/1.1.2.
352
- * Security fix in Rack::Auth::Digest::MD5: when authenticator
353
- returned nil, permission was granted on empty password.
354
-
355
- * May 22nd, 2011: Thirteenth public release 1.3.0
356
- * Various performance optimizations
357
- * Various multipart fixes
358
- * Various multipart refactors
359
- * Infinite loop fix for multipart
360
- * Test coverage for Rack::Server returns
361
- * Allow files with '..', but not path components that are '..'
362
- * rackup accepts handler-specific options on the command line
363
- * Request#params no longer merges POST into GET (but returns the same)
364
- * Use URI.encode_www_form_component instead. Use core methods for escaping.
365
- * Allow multi-line comments in the config file
366
- * Bug L#94 reported by Nikolai Lugovoi, query parameter unescaping.
367
- * Rack::Response now deletes Content-Length when appropriate
368
- * Rack::Deflater now supports streaming
369
- * Improved Rack::Handler loading and searching
370
- * Support for the PATCH verb
371
- * env['rack.session.options'] now contains session options
372
- * Cookies respect renew
373
- * Session middleware uses SecureRandom.hex
374
-
375
- * May 22nd, 2011: Fourteenth public release 1.2.3
376
- * Pulled in relevant bug fixes from 1.3
377
- * Fixed 1.8.6 support
378
-
379
- * July 13, 2011: Fifteenth public release 1.3.1
380
- * Fix 1.9.1 support
381
- * Fix JRuby support
382
- * Properly handle $KCODE in Rack::Utils.escape
383
- * Make method_missing/respond_to behavior consistent for Rack::Lock,
384
- Rack::Auth::Digest::Request and Rack::Multipart::UploadedFile
385
- * Reenable passing rack.session to session middleware
386
- * Rack::CommonLogger handles streaming responses correctly
387
- * Rack::MockResponse calls close on the body object
388
- * Fix a DOS vector from MRI stdlib backport
389
-
390
- * July 16, 2011: Sixteenth public release 1.3.2
391
- * Fix for Rails and rack-test, Rack::Utils#escape calls to_s
392
-
393
- * September 16, 2011: Seventeenth public release 1.3.3
394
- * Fix bug with broken query parameters in Rack::ShowExceptions
395
- * Rack::Request#cookies no longer swallows exceptions on broken input
396
- * Prevents XSS attacks enabled by bug in Ruby 1.8's regexp engine
397
- * Rack::ConditionalGet handles broken If-Modified-Since helpers
398
-
399
- * September 16, 2011: Eighteenth public release 1.2.4
400
- * Fix a bug with MRI regex engine to prevent XSS by malformed unicode
401
-
402
- * October 1, 2011: Nineteenth public release 1.3.4
403
- * Backport security fix from 1.9.3, also fixes some roundtrip issues in URI
404
- * Small documentation update
405
- * Fix an issue where BodyProxy could cause an infinite recursion
406
- * Add some supporting files for travis-ci
407
-
408
- * October 17, 2011: Twentieth public release 1.3.5
409
- * Fix annoying warnings caused by the backport in 1.3.4
410
-
411
- * December 28th, 2011: Twenty first public release: 1.1.3.
412
- * Security fix. http://www.ocert.org/advisories/ocert-2011-003.html
413
- Further information here: http://jruby.org/2011/12/27/jruby-1-6-5-1
414
-
415
- * December 28th, 2011: Twenty fourth public release 1.4.0
416
- * Ruby 1.8.6 support has officially been dropped. Not all tests pass.
417
- * Raise sane error messages for broken config.ru
418
- * Allow combining run and map in a config.ru
419
- * Rack::ContentType will not set Content-Type for responses without a body
420
- * Status code 205 does not send a response body
421
- * Rack::Response::Helpers will not rely on instance variables
422
- * Rack::Utils.build_query no longer outputs '=' for nil query values
423
- * Various mime types added
424
- * Rack::MockRequest now supports HEAD
425
- * Rack::Directory now supports files that contain RFC3986 reserved chars
426
- * Rack::File now only supports GET and HEAD requests
427
- * Rack::Server#start now passes the block to Rack::Handler::<h>#run
428
- * Rack::Static now supports an index option
429
- * Added the Teapot status code
430
- * rackup now defaults to Thin instead of Mongrel (if installed)
431
- * Support added for HTTP_X_FORWARDED_SCHEME
432
- * Numerous bug fixes, including many fixes for new and alternate rubies
433
-
434
- * January 22nd, 2012: Twenty fifth public release 1.4.1
435
- * Alter the keyspace limit calculations to reduce issues with nested params
436
- * Add a workaround for multipart parsing where files contain unescaped "%"
437
- * Added Rack::Response::Helpers#method_not_allowed? (code 405)
438
- * Rack::File now returns 404 for illegal directory traversals
439
- * Rack::File now returns 405 for illegal methods (non HEAD/GET)
440
- * Rack::Cascade now catches 405 by default, as well as 404
441
- * Cookies missing '--' no longer cause an exception to be raised
442
- * Various style changes and documentation spelling errors
443
- * Rack::BodyProxy always ensures to execute its block
444
- * Additional test coverage around cookies and secrets
445
- * Rack::Session::Cookie can now be supplied either secret or old_secret
446
- * Tests are no longer dependent on set order
447
- * Rack::Static no longer defaults to serving index files
448
- * Rack.release was fixed
449
-
450
- * January 6th, 2013: Twenty sixth public release 1.1.4
451
- * Add warnings when users do not provide a session secret
452
-
453
- * January 6th, 2013: Twenty seventh public release 1.2.6
454
- * Add warnings when users do not provide a session secret
455
- * Fix parsing performance for unquoted filenames
456
-
457
- * January 6th, 2013: Twenty eighth public release 1.3.7
458
- * Add warnings when users do not provide a session secret
459
- * Fix parsing performance for unquoted filenames
460
- * Updated URI backports
461
- * Fix URI backport version matching, and silence constant warnings
462
- * Correct parameter parsing with empty values
463
- * Correct rackup '-I' flag, to allow multiple uses
464
- * Correct rackup pidfile handling
465
- * Report rackup line numbers correctly
466
- * Fix request loops caused by non-stale nonces with time limits
467
- * Fix reloader on Windows
468
- * Prevent infinite recursions from Response#to_ary
469
- * Various middleware better conforms to the body close specification
470
- * Updated language for the body close specification
471
- * Additional notes regarding ECMA escape compatibility issues
472
- * Fix the parsing of multiple ranges in range headers
473
-
474
- * January 6th, 2013: Twenty ninth public release 1.4.2
475
- * Add warnings when users do not provide a session secret
476
- * Fix parsing performance for unquoted filenames
477
- * Updated URI backports
478
- * Fix URI backport version matching, and silence constant warnings
479
- * Correct parameter parsing with empty values
480
- * Correct rackup '-I' flag, to allow multiple uses
481
- * Correct rackup pidfile handling
482
- * Report rackup line numbers correctly
483
- * Fix request loops caused by non-stale nonces with time limits
484
- * Fix reloader on Windows
485
- * Prevent infinite recursions from Response#to_ary
486
- * Various middleware better conforms to the body close specification
487
- * Updated language for the body close specification
488
- * Additional notes regarding ECMA escape compatibility issues
489
- * Fix the parsing of multiple ranges in range headers
490
- * Prevent errors from empty parameter keys
491
- * Added PATCH verb to Rack::Request
492
- * Various documentation updates
493
- * Fix session merge semantics (fixes rack-test)
494
- * Rack::Static :index can now handle multiple directories
495
- * All tests now utilize Rack::Lint (special thanks to Lars Gierth)
496
- * Rack::File cache_control parameter is now deprecated, and removed by 1.5
497
- * Correct Rack::Directory script name escaping
498
- * Rack::Static supports header rules for sophisticated configurations
499
- * Multipart parsing now works without a Content-Length header
500
- * New logos courtesy of Zachary Scott!
501
- * Rack::BodyProxy now explicitly defines #each, useful for C extensions
502
- * Cookies that are not URI escaped no longer cause exceptions
503
-
504
- * January 7th, 2013: Thirtieth public release 1.3.8
505
- * Security: Prevent unbounded reads in large multipart boundaries
506
-
507
- * January 7th, 2013: Thirty first public release 1.4.3
508
- * Security: Prevent unbounded reads in large multipart boundaries
509
-
510
- * January 13th, 2013: Thirty second public release 1.4.4, 1.3.9, 1.2.7, 1.1.5
511
- * [SEC] Rack::Auth::AbstractRequest no longer symbolizes arbitrary strings
512
- * Fixed erroneous test case in the 1.3.x series
513
-
514
- * January 21st, 2013: Thirty third public release 1.5.0
515
- * Introduced hijack SPEC, for before-response and after-response hijacking
516
- * SessionHash is no longer a Hash subclass
517
- * Rack::File cache_control parameter is removed, in place of headers options
518
- * Rack::Auth::AbstractRequest#scheme now yields strings, not symbols
519
- * Rack::Utils cookie functions now format expires in RFC 2822 format
520
- * Rack::File now has a default mime type
521
- * rackup -b 'run Rack::File.new(".")', option provides command line configs
522
- * Rack::Deflater will no longer double encode bodies
523
- * Rack::Mime#match? provides convenience for Accept header matching
524
- * Rack::Utils#q_values provides splitting for Accept headers
525
- * Rack::Utils#best_q_match provides a helper for Accept headers
526
- * Rack::Handler.pick provides convenience for finding available servers
527
- * Puma added to the list of default servers (preferred over Webrick)
528
- * Various middleware now correctly close body when replacing it
529
- * Rack::Request#params is no longer persistent with only GET params
530
- * Rack::Request#update_param and #delete_param provide persistent operations
531
- * Rack::Request#trusted_proxy? now returns true for local unix sockets
532
- * Rack::Response no longer forces Content-Types
533
- * Rack::Sendfile provides local mapping configuration options
534
- * Rack::Utils#rfc2109 provides old netscape style time output
535
- * Updated HTTP status codes
536
- * Ruby 1.8.6 likely no longer passes tests, and is no longer fully supported
537
-
538
- * January 28th, 2013: Thirty fourth public release 1.5.1
539
- * Rack::Lint check_hijack now conforms to other parts of SPEC
540
- * Added hash-like methods to Abstract::ID::SessionHash for compatibility
541
- * Various documentation corrections
542
-
543
- * February 7th, Thirty fifth public release 1.1.6, 1.2.8, 1.3.10
544
- * Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
545
-
546
- * February 7th, Thirty fifth public release 1.4.5
547
- * Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
548
- * Fix CVE-2013-0262, symlink path traversal in Rack::File
549
-
550
- * February 7th, Thirty fifth public release 1.5.2
551
- * Fix CVE-2013-0263, timing attack against Rack::Session::Cookie
552
- * Fix CVE-2013-0262, symlink path traversal in Rack::File
553
- * Add various methods to Session for enhanced Rails compatibility
554
- * Request#trusted_proxy? now only matches whole stirngs
555
- * Add JSON cookie coder, to be default in Rack 1.6+ due to security concerns
556
- * URLMap host matching in environments that don't set the Host header fixed
557
- * Fix a race condition that could result in overwritten pidfiles
558
- * Various documentation additions
212
+ See <https://github.com/rack/HISTORY.md>.
559
213
 
560
214
  == Contact
561
215
 
562
216
  Please post bugs, suggestions and patches to
563
- the bug tracker at <http://github.com/rack/rack/issues>.
217
+ the bug tracker at <https://github.com/rack/rack/issues>.
564
218
 
565
219
  Please post security related bugs and suggestions to the core team at
566
220
  <https://groups.google.com/group/rack-core> or rack-core@googlegroups.com. This
@@ -569,10 +223,10 @@ that we manage timing in order to provide viable patches at the time of
569
223
  disclosure. Your assistance in this matter is greatly appreciated.
570
224
 
571
225
  Mailing list archives are available at
572
- <http://groups.google.com/group/rack-devel>.
226
+ <https://groups.google.com/group/rack-devel>.
573
227
 
574
228
  Git repository (send Git patches to the mailing list):
575
- * http://github.com/rack/rack
229
+ * https://github.com/rack/rack
576
230
  * http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack-github.git
577
231
 
578
232
  You are also welcome to join the #rack channel on irc.freenode.net.
@@ -649,9 +303,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
649
303
  == Links
650
304
 
651
305
  Rack:: <http://rack.github.io/>
652
- Official Rack repositories:: <http://github.com/rack>
653
- Rack Bug Tracking:: <http://github.com/rack/rack/issues>
654
- rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
306
+ Official Rack repositories:: <https://github.com/rack>
307
+ Rack Bug Tracking:: <https://github.com/rack/rack/issues>
308
+ rack-devel mailing list:: <https://groups.google.com/group/rack-devel>
655
309
  Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
656
310
 
657
311
  Christian Neukirchen:: <http://chneukirchen.org/>
data/Rakefile CHANGED
@@ -90,7 +90,7 @@ task :test => 'SPEC' do
90
90
  end
91
91
 
92
92
  desc "Run all the tests we run on CI"
93
- task :ci => :test
93
+ task :ci => :fulltest
94
94
 
95
95
  desc "Run all the tests"
96
96
  task :fulltest => %w[SPEC chmod] do
@@ -20,7 +20,7 @@ module Rack
20
20
 
21
21
  # Return the Rack release as a dotted string.
22
22
  def self.release
23
- "1.5"
23
+ "1.6.1"
24
24
  end
25
25
  PATH_INFO = 'PATH_INFO'.freeze
26
26
  REQUEST_METHOD = 'REQUEST_METHOD'.freeze
@@ -639,7 +639,7 @@ module Rack
639
639
  assert("header must not contain Status") { key.downcase != "status" }
640
640
  ## The header must conform to RFC7230 token specification, i.e. cannot
641
641
  ## contain non-printable ASCII, DQUOTE or "(),/:;<=>?@[\]{}".
642
- assert("invalid header name: #{key}") { key !~ /[\(\),\/:;<=>\?@\[\\\]{}[[:cntrl:]]]/ }
642
+ assert("invalid header name: #{key}") { key !~ /[\(\),\/:;<=>\?@\[\\\]{}[:cntrl:]]/ }
643
643
 
644
644
  ## The values of the header must be Strings,
645
645
  assert("a header value must be a String, but the value of " +
@@ -14,9 +14,9 @@ module Rack
14
14
 
15
15
  FORMAT_STRING = "%0.6f"
16
16
  def call(env)
17
- start_time = Time.now
17
+ start_time = clock_time
18
18
  status, headers, body = @app.call(env)
19
- request_time = Time.now - start_time
19
+ request_time = clock_time - start_time
20
20
 
21
21
  if !headers.has_key?(@header_name)
22
22
  headers[@header_name] = FORMAT_STRING % request_time
@@ -24,5 +24,17 @@ module Rack
24
24
 
25
25
  [status, headers, body]
26
26
  end
27
+
28
+ private
29
+
30
+ if defined?(Process::CLOCK_MONOTONIC)
31
+ def clock_time
32
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
33
+ end
34
+ else
35
+ def clock_time
36
+ Time.now.to_f
37
+ end
38
+ end
27
39
  end
28
40
  end
@@ -50,7 +50,7 @@ module Rack
50
50
  options[:server] = s
51
51
  }
52
52
 
53
- opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host|
53
+ opts.on("-o", "--host HOST", "listen on HOST (default: localhost)") { |host|
54
54
  options[:Host] = host
55
55
  }
56
56
 
@@ -71,7 +71,8 @@ module Rack
71
71
  # The maximum number of parts a request can contain. Accepting too many part
72
72
  # can lead to the server running out of file handles.
73
73
  # Set to `0` for no limit.
74
- self.multipart_part_limit = (ENV['RACK_MULTIPART_LIMIT'] || 128).to_i
74
+ # FIXME: RACK_MULTIPART_LIMIT was introduced by mistake and it will be removed in 1.7.0
75
+ self.multipart_part_limit = (ENV['RACK_MULTIPART_PART_LIMIT'] || ENV['RACK_MULTIPART_LIMIT'] || 128).to_i
75
76
 
76
77
  # Stolen from Mongrel, with some small modifications:
77
78
  # Parses a query string by breaking it up at the '&'
@@ -21,16 +21,14 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  # See https://github.com/kr/okjson for updates.
24
- # Imported from the above repo @ d4e8643ad92e14b37d11326855499c7e4108ed17
25
- # Namespace modified for vendoring under Rack::Utils
26
24
 
27
25
  require 'stringio'
28
26
 
29
27
  # Some parts adapted from
30
- # http://golang.org/src/pkg/json/decode.go and
31
- # http://golang.org/src/pkg/utf8/utf8.go
28
+ # https://golang.org/src/encoding/json/decode.go and
29
+ # https://golang.org/src/unicode/utf8/utf8.go
32
30
  module Rack::Utils::OkJson
33
- Upstream = 'LTD7LBKLZWFF7OZK'
31
+ Upstream = '43'
34
32
  extend self
35
33
 
36
34
 
@@ -52,12 +50,49 @@ module Rack::Utils::OkJson
52
50
  end
53
51
 
54
52
 
53
+ # Encodes x into a json text. It may contain only
54
+ # Array, Hash, String, Numeric, true, false, nil.
55
+ # (Note, this list excludes Symbol.)
56
+ # X itself must be an Array or a Hash.
57
+ # No other value can be encoded, and an error will
58
+ # be raised if x contains any other value, such as
59
+ # Nan, Infinity, Symbol, and Proc, or if a Hash key
60
+ # is not a String.
61
+ # Strings contained in x must be valid UTF-8.
62
+ def encode(x)
63
+ case x
64
+ when Hash then objenc(x)
65
+ when Array then arrenc(x)
66
+ else
67
+ raise Error, 'root value must be an Array or a Hash'
68
+ end
69
+ end
70
+
71
+
72
+ def valenc(x)
73
+ case x
74
+ when Hash then objenc(x)
75
+ when Array then arrenc(x)
76
+ when String then strenc(x)
77
+ when Numeric then numenc(x)
78
+ when true then "true"
79
+ when false then "false"
80
+ when nil then "null"
81
+ else
82
+ raise Error, "cannot encode #{x.class}: #{x.inspect}"
83
+ end
84
+ end
85
+
86
+
87
+ private
88
+
89
+
55
90
  # Parses a "json text" in the sense of RFC 4627.
56
91
  # Returns the parsed value and any trailing tokens.
57
92
  # Note: this is almost the same as valparse,
58
93
  # except that it does not accept atomic values.
59
94
  def textparse(ts)
60
- if ts.length < 0
95
+ if ts.length <= 0
61
96
  raise Error, 'empty'
62
97
  end
63
98
 
@@ -74,7 +109,7 @@ module Rack::Utils::OkJson
74
109
  # Parses a "value" in the sense of RFC 4627.
75
110
  # Returns the parsed value and any trailing tokens.
76
111
  def valparse(ts)
77
- if ts.length < 0
112
+ if ts.length <= 0
78
113
  raise Error, 'empty'
79
114
  end
80
115
 
@@ -203,21 +238,19 @@ module Rack::Utils::OkJson
203
238
  # it is the lexeme.
204
239
  def tok(s)
205
240
  case s[0]
206
- when ?{ then ['{', s[0,1], s[0,1]]
207
- when ?} then ['}', s[0,1], s[0,1]]
208
- when ?: then [':', s[0,1], s[0,1]]
209
- when ?, then [',', s[0,1], s[0,1]]
210
- when ?[ then ['[', s[0,1], s[0,1]]
211
- when ?] then [']', s[0,1], s[0,1]]
212
- when ?n then nulltok(s)
213
- when ?t then truetok(s)
214
- when ?f then falsetok(s)
215
- when ?" then strtok(s)
216
- when Spc then [:space, s[0,1], s[0,1]]
217
- when ?\t then [:space, s[0,1], s[0,1]]
218
- when ?\n then [:space, s[0,1], s[0,1]]
219
- when ?\r then [:space, s[0,1], s[0,1]]
220
- else numtok(s)
241
+ when ?{ then ['{', s[0,1], s[0,1]]
242
+ when ?} then ['}', s[0,1], s[0,1]]
243
+ when ?: then [':', s[0,1], s[0,1]]
244
+ when ?, then [',', s[0,1], s[0,1]]
245
+ when ?[ then ['[', s[0,1], s[0,1]]
246
+ when ?] then [']', s[0,1], s[0,1]]
247
+ when ?n then nulltok(s)
248
+ when ?t then truetok(s)
249
+ when ?f then falsetok(s)
250
+ when ?" then strtok(s)
251
+ when Spc, ?\t, ?\n, ?\r then [:space, s[0,1], s[0,1]]
252
+ else
253
+ numtok(s)
221
254
  end
222
255
  end
223
256
 
@@ -230,12 +263,12 @@ module Rack::Utils::OkJson
230
263
  def numtok(s)
231
264
  m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s)
232
265
  if m && m.begin(0) == 0
233
- if m[3] && !m[2]
234
- [:val, m[0], Integer(m[1])*(10**Integer(m[3][1..-1]))]
266
+ if !m[2] && !m[3]
267
+ [:val, m[0], Integer(m[0])]
235
268
  elsif m[2]
236
269
  [:val, m[0], Float(m[0])]
237
270
  else
238
- [:val, m[0], Integer(m[0])]
271
+ [:val, m[0], Integer(m[1])*(10**m[3][1..-1].to_i(10))]
239
272
  end
240
273
  else
241
274
  []
@@ -267,17 +300,14 @@ module Rack::Utils::OkJson
267
300
  def unquote(q)
268
301
  q = q[1...-1]
269
302
  a = q.dup # allocate a big enough string
270
- rubydoesenc = false
271
303
  # In ruby >= 1.9, a[w] is a codepoint, not a byte.
272
- if a.class.method_defined?(:force_encoding)
304
+ if rubydoesenc?
273
305
  a.force_encoding('UTF-8')
274
- rubydoesenc = true
275
306
  end
276
307
  r, w = 0, 0
277
308
  while r < q.length
278
309
  c = q[r]
279
- case true
280
- when c == ?\\
310
+ if c == ?\\
281
311
  r += 1
282
312
  if r >= q.length
283
313
  raise Error, "string literal ends with a \"\\\": \"#{q}\""
@@ -310,7 +340,7 @@ module Rack::Utils::OkJson
310
340
  end
311
341
  end
312
342
  end
313
- if rubydoesenc
343
+ if rubydoesenc?
314
344
  a[w] = '' << uchar
315
345
  w += 1
316
346
  else
@@ -319,7 +349,7 @@ module Rack::Utils::OkJson
319
349
  else
320
350
  raise Error, "invalid escape char #{q[r]} in \"#{q}\""
321
351
  end
322
- when c == ?", c < Spc
352
+ elsif c == ?" || c < Spc
323
353
  raise Error, "invalid character in string literal \"#{q}\""
324
354
  else
325
355
  # Copy anything else byte-for-byte.
@@ -340,15 +370,14 @@ module Rack::Utils::OkJson
340
370
  # bytes in string a at position i.
341
371
  # Returns the number of bytes written.
342
372
  def ucharenc(a, i, u)
343
- case true
344
- when u <= Uchar1max
373
+ if u <= Uchar1max
345
374
  a[i] = (u & 0xff).chr
346
375
  1
347
- when u <= Uchar2max
376
+ elsif u <= Uchar2max
348
377
  a[i+0] = (Utag2 | ((u>>6)&0xff)).chr
349
378
  a[i+1] = (Utagx | (u&Umaskx)).chr
350
379
  2
351
- when u <= Uchar3max
380
+ elsif u <= Uchar3max
352
381
  a[i+0] = (Utag3 | ((u>>12)&0xff)).chr
353
382
  a[i+1] = (Utagx | ((u>>6)&Umaskx)).chr
354
383
  a[i+2] = (Utagx | (u&Umaskx)).chr
@@ -385,50 +414,15 @@ module Rack::Utils::OkJson
385
414
 
386
415
 
387
416
  def nibble(c)
388
- case true
389
- when ?0 <= c && c <= ?9 then c.ord - ?0.ord
390
- when ?a <= c && c <= ?z then c.ord - ?a.ord + 10
391
- when ?A <= c && c <= ?Z then c.ord - ?A.ord + 10
417
+ if ?0 <= c && c <= ?9 then c.ord - ?0.ord
418
+ elsif ?a <= c && c <= ?z then c.ord - ?a.ord + 10
419
+ elsif ?A <= c && c <= ?Z then c.ord - ?A.ord + 10
392
420
  else
393
421
  raise Error, "invalid hex code #{c}"
394
422
  end
395
423
  end
396
424
 
397
425
 
398
- # Encodes x into a json text. It may contain only
399
- # Array, Hash, String, Numeric, true, false, nil.
400
- # (Note, this list excludes Symbol.)
401
- # X itself must be an Array or a Hash.
402
- # No other value can be encoded, and an error will
403
- # be raised if x contains any other value, such as
404
- # Nan, Infinity, Symbol, and Proc, or if a Hash key
405
- # is not a String.
406
- # Strings contained in x must be valid UTF-8.
407
- def encode(x)
408
- case x
409
- when Hash then objenc(x)
410
- when Array then arrenc(x)
411
- else
412
- raise Error, 'root value must be an Array or a Hash'
413
- end
414
- end
415
-
416
-
417
- def valenc(x)
418
- case x
419
- when Hash then objenc(x)
420
- when Array then arrenc(x)
421
- when String then strenc(x)
422
- when Numeric then numenc(x)
423
- when true then "true"
424
- when false then "false"
425
- when nil then "null"
426
- else
427
- raise Error, "cannot encode #{x.class}: #{x.inspect}"
428
- end
429
- end
430
-
431
-
432
426
  def objenc(x)
433
427
  '{' + x.map{|k,v| keyenc(k) + ':' + valenc(v)}.join(',') + '}'
434
428
  end
@@ -453,9 +447,6 @@ module Rack::Utils::OkJson
453
447
  t.putc(?")
454
448
  r = 0
455
449
 
456
- # In ruby >= 1.9, s[r] is a codepoint, not a byte.
457
- rubydoesenc = s.class.method_defined?(:encoding)
458
-
459
450
  while r < s.length
460
451
  case s[r]
461
452
  when ?" then t.print('\\"')
@@ -467,15 +458,20 @@ module Rack::Utils::OkJson
467
458
  when ?\t then t.print('\\t')
468
459
  else
469
460
  c = s[r]
470
- case true
471
- when rubydoesenc
461
+ # In ruby >= 1.9, s[r] is a codepoint, not a byte.
462
+ if rubydoesenc?
472
463
  begin
473
- c.ord # will raise an error if c is invalid UTF-8
464
+ # c.ord will raise an error if c is invalid UTF-8
465
+ if c.ord < Spc.ord
466
+ c = "\\u%04x" % [c.ord]
467
+ end
474
468
  t.write(c)
475
469
  rescue
476
470
  t.write(Ustrerr)
477
471
  end
478
- when Spc <= c && c <= ?~
472
+ elsif c < Spc
473
+ t.write("\\u%04x" % c)
474
+ elsif Spc <= c && c <= ?~
479
475
  t.putc(c)
480
476
  else
481
477
  n = ucharcopy(t, s, r) # ensure valid UTF-8 output
@@ -567,6 +563,11 @@ module Rack::Utils::OkJson
567
563
  end
568
564
 
569
565
 
566
+ def rubydoesenc?
567
+ ::String.method_defined?(:force_encoding)
568
+ end
569
+
570
+
570
571
  class Utf8Error < ::StandardError
571
572
  end
572
573
 
@@ -575,15 +576,15 @@ module Rack::Utils::OkJson
575
576
  end
576
577
 
577
578
 
578
- Utagx = 0x80 # 1000 0000
579
- Utag2 = 0xc0 # 1100 0000
580
- Utag3 = 0xe0 # 1110 0000
581
- Utag4 = 0xf0 # 1111 0000
582
- Utag5 = 0xF8 # 1111 1000
583
- Umaskx = 0x3f # 0011 1111
584
- Umask2 = 0x1f # 0001 1111
585
- Umask3 = 0x0f # 0000 1111
586
- Umask4 = 0x07 # 0000 0111
579
+ Utagx = 0b1000_0000
580
+ Utag2 = 0b1100_0000
581
+ Utag3 = 0b1110_0000
582
+ Utag4 = 0b1111_0000
583
+ Utag5 = 0b1111_1000
584
+ Umaskx = 0b0011_1111
585
+ Umask2 = 0b0001_1111
586
+ Umask3 = 0b0000_1111
587
+ Umask4 = 0b0000_0111
587
588
  Uchar1max = (1<<7) - 1
588
589
  Uchar2max = (1<<11) - 1
589
590
  Uchar3max = (1<<16) - 1
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack"
3
- s.version = "1.6.0"
3
+ s.version = "1.6.1"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "a modular Ruby webserver interface"
6
6
  s.license = "MIT"
@@ -20,7 +20,7 @@ EOF
20
20
  s.bindir = 'bin'
21
21
  s.executables << 'rackup'
22
22
  s.require_path = 'lib'
23
- s.extra_rdoc_files = ['README.rdoc', 'KNOWN-ISSUES']
23
+ s.extra_rdoc_files = ['README.rdoc', 'KNOWN-ISSUES', 'HISTORY.md']
24
24
  s.test_files = Dir['test/spec_*.rb']
25
25
 
26
26
  s.author = 'Christian Neukirchen'
@@ -43,7 +43,7 @@ describe Rack::Handler::CGI do
43
43
 
44
44
  should "have rack headers" do
45
45
  GET("/test")
46
- response["rack.version"].should.equal([1,2])
46
+ response["rack.version"].should.equal([1,3])
47
47
  response["rack.multithread"].should.be.false
48
48
  response["rack.multiprocess"].should.be.true
49
49
  response["rack.run_once"].should.be.true
@@ -48,7 +48,7 @@ describe Rack::Handler::FastCGI do
48
48
 
49
49
  should "have rack headers" do
50
50
  GET("/test.fcgi")
51
- response["rack.version"].should.equal [1,2]
51
+ response["rack.version"].should.equal [1,3]
52
52
  response["rack.multithread"].should.be.false
53
53
  response["rack.multiprocess"].should.be.true
54
54
  response["rack.run_once"].should.be.false
@@ -36,7 +36,7 @@ describe Rack::Handler::Mongrel do
36
36
 
37
37
  should "have rack headers" do
38
38
  GET("/test")
39
- response["rack.version"].should.equal [1,2]
39
+ response["rack.version"].should.equal [1,3]
40
40
  response["rack.multithread"].should.be.true
41
41
  response["rack.multiprocess"].should.be.false
42
42
  response["rack.run_once"].should.be.false
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rack'
3
+
4
+ describe Rack do
5
+ describe 'version' do
6
+ it 'defaults to a hard-coded api version' do
7
+ Rack.version.should.equal("1.3")
8
+ end
9
+ end
10
+ describe 'release' do
11
+ it 'matches version in .gemspec' do
12
+ gemspec_path = File.join(File.dirname(File.expand_path(__FILE__)), '../rack.gemspec')
13
+ gemspec = Gem::Specification.load(gemspec_path)
14
+ Rack.release.split('.').take(2).should.equal gemspec.version.to_s.split('.').take(2)
15
+ end
16
+ end
17
+ end
@@ -33,7 +33,7 @@ describe Rack::Handler::WEBrick do
33
33
 
34
34
  should "have rack headers" do
35
35
  GET("/test")
36
- response["rack.version"].should.equal [1,2]
36
+ response["rack.version"].should.equal [1,3]
37
37
  response["rack.multithread"].should.be.true
38
38
  response["rack.multiprocess"].should.be.false
39
39
  response["rack.run_once"].should.be.false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neukirchen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bacon
@@ -53,8 +53,10 @@ extensions: []
53
53
  extra_rdoc_files:
54
54
  - README.rdoc
55
55
  - KNOWN-ISSUES
56
+ - HISTORY.md
56
57
  files:
57
58
  - COPYING
59
+ - HISTORY.md
58
60
  - KNOWN-ISSUES
59
61
  - README.rdoc
60
62
  - Rakefile
@@ -225,6 +227,7 @@ files:
225
227
  - test/spec_thin.rb
226
228
  - test/spec_urlmap.rb
227
229
  - test/spec_utils.rb
230
+ - test/spec_version.rb
228
231
  - test/spec_webrick.rb
229
232
  - test/static/another/index.html
230
233
  - test/static/index.html
@@ -251,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
254
  version: '0'
252
255
  requirements: []
253
256
  rubyforge_project: rack
254
- rubygems_version: 2.4.5
257
+ rubygems_version: 2.4.6
255
258
  signing_key:
256
259
  specification_version: 4
257
260
  summary: a modular Ruby webserver interface
@@ -303,4 +306,6 @@ test_files:
303
306
  - test/spec_thin.rb
304
307
  - test/spec_urlmap.rb
305
308
  - test/spec_utils.rb
309
+ - test/spec_version.rb
306
310
  - test/spec_webrick.rb
311
+ has_rdoc: