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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/down/chunked_io.rb +13 -1
- data/lib/down/utils.rb +6 -2
- data/lib/down/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d16d04f8312202b900d1384a3b859ffa9020eb1e4b00a83ad74f49d0211953d
|
4
|
+
data.tar.gz: 2b473d352ee773333efe32bbd11d38597c3bf3edc66d1808c9888de3d0cc09cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93016da86cad0833589bb4a31068181675bb16a22d94de9332650782cea764b1ea815685202b8a8eea88dedff89b8f35cfd70f884104739437589adffab4b76b
|
7
|
+
data.tar.gz: 4fbc673a14247f63e0616e0b87d4f5b6ad038dc2eecb476725a2d0c74424101c22a28d16700418979418b0b9f4c1d378e2c00cb6f6c9b91f1412bcd5ee36c890
|
data/CHANGELOG.md
CHANGED
@@ -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
data/lib/down/chunked_io.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/down/utils.rb
CHANGED
@@ -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
|
-
|
12
|
-
|
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
|
data/lib/down/version.rb
CHANGED
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.
|
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
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|