down 4.7.0 → 4.8.0

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
  SHA256:
3
- metadata.gz: 2a731d7a9096d275efb334bb06f6a7d2060f9711ac8973f4db286170a0f288e9
4
- data.tar.gz: 89924b87d6fea6ba6fb3d5fc2ceed6d50a312758a1a9ec57baaeeaefd5283a8f
3
+ metadata.gz: 3d16d04f8312202b900d1384a3b859ffa9020eb1e4b00a83ad74f49d0211953d
4
+ data.tar.gz: 2b473d352ee773333efe32bbd11d38597c3bf3edc66d1808c9888de3d0cc09cf
5
5
  SHA512:
6
- metadata.gz: f63e9bbf2f5e8f10105816ffc9369f5aff75e65667ffb85e0e0c71f96c0b1861c5e727d379c55fd5695855e409ca49c306ce70fa5927a7bbb826cfb780b2ac77
7
- data.tar.gz: 49db0e8cee2494962384613c4cbb84b232e3e9a6872cc13a19e7a4b4f86b86e09e70a65620ab1c067a8557f0ae43de9d37f2fc0255d8fed42e46ed4705aa7911
6
+ metadata.gz: 93016da86cad0833589bb4a31068181675bb16a22d94de9332650782cea764b1ea815685202b8a8eea88dedff89b8f35cfd70f884104739437589adffab4b76b
7
+ data.tar.gz: 4fbc673a14247f63e0616e0b87d4f5b6ad038dc2eecb476725a2d0c74424101c22a28d16700418979418b0b9f4c1d378e2c00cb6f6c9b91f1412bcd5ee36c890
@@ -1,3 +1,9 @@
1
+ ## 4.8.0 (2018-12-19)
2
+
3
+ * Prefer UTF-8 filenames in `Content-Disposition` header for `Tempfile#original_filename` (@janko-m)
4
+
5
+ * Make the internal Tempfile of `Down::ChunkedIO` inaccessible to outside programs (@janko-m)
6
+
1
7
  ## 4.7.0 (2018-11-18)
2
8
 
3
9
  * Allow request headers to be passed via `:headers` to `Down::NetHttp#download` and `#open` (@janko-m)
data/README.md CHANGED
@@ -338,7 +338,7 @@ net_http.open("http://example.com/image.jpg")
338
338
 
339
339
  ```rb
340
340
  gem "down", "~> 4.4"
341
- gem "http", "~> 3.2"
341
+ gem "http", "~> 4.0"
342
342
  ```
343
343
  ```rb
344
344
  require "down/http"
@@ -256,7 +256,14 @@ module Down
256
256
  # If Down::ChunkedIO is specified as rewindable, returns a new Tempfile for
257
257
  # writing read content to. This allows the Down::ChunkedIO to be rewinded.
258
258
  def cache
259
- @cache ||= Tempfile.new("down-chunked_io", binmode: true) if @rewindable
259
+ return if !rewindable?
260
+
261
+ @cache ||= (
262
+ tempfile = Tempfile.new("down-chunked_io", binmode: true)
263
+ tempfile.chmod(0000) # make sure nobody else can read or write to it
264
+ tempfile.unlink if posix? # remove entry from filesystem if it's POSIX
265
+ tempfile
266
+ )
260
267
  end
261
268
 
262
269
  # Returns current chunk and retrieves the next chunk. If next chunk is nil,
@@ -296,5 +303,10 @@ module Down
296
303
  rescue ArgumentError
297
304
  Encoding::BINARY
298
305
  end
306
+
307
+ # Returns whether the filesystem has POSIX semantics.
308
+ def posix?
309
+ RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/
310
+ end
299
311
  end
300
312
  end
@@ -8,8 +8,12 @@ module Down
8
8
  def filename_from_content_disposition(content_disposition)
9
9
  content_disposition = content_disposition.to_s
10
10
 
11
- filename = content_disposition[/filename="([^"]*)"/, 1] || content_disposition[/filename=(.+)/, 1]
12
- filename = CGI.unescape(filename.to_s.strip)
11
+ escaped_filename =
12
+ content_disposition[/filename\*=UTF-8''(\S+)/, 1] ||
13
+ content_disposition[/filename="([^"]*)"/, 1] ||
14
+ content_disposition[/filename=(\S+)/, 1]
15
+
16
+ filename = CGI.unescape(escaped_filename.to_s)
13
17
 
14
18
  filename unless filename.empty?
15
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen-string-literal: true
2
2
 
3
3
  module Down
4
- VERSION = "4.7.0"
4
+ VERSION = "4.8.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: down
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-18 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable