files.com 1.1.781 → 1.1.782
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 +4 -4
- data/_VERSION +1 -1
- data/lib/files.com/models/file.rb +21 -2
- data/lib/files.com/version.rb +1 -1
- data/spec/models/file_download_default_path_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddcd318206fe185a4e00ccbfb7d6d2d4655a1f7810800a341bbfbe5132d17a17
|
|
4
|
+
data.tar.gz: 65523517081a2759ad980a8cf43198e49bbb684609ba5d4512adda9ead3cf78b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84dabf3483704390c691c4e2cb5b0ba75d7c12ef96e0a0559512cb7ebc674d8cf43813a720df47b7e8b4a3b9518ed0d3bace0f3ffc23fa95acf8e8f5dbcd2617
|
|
7
|
+
data.tar.gz: 2873fd9698c3b0395217b4463d5613d39b6c42f7c70e0b0cbf29dec4d337095906494feadd85c04ec2a0735f381d248b0ff56a2ce57f6efac30acba0f35e3d1f
|
data/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.782
|
|
@@ -5,6 +5,13 @@ module Files
|
|
|
5
5
|
attr_reader :options, :attributes
|
|
6
6
|
attr_reader :mode
|
|
7
7
|
|
|
8
|
+
WINDOWS_DEVICE_NAMES = [
|
|
9
|
+
"CON", "PRN", "AUX", "NUL", "CONIN$", "CONOUT$",
|
|
10
|
+
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM\u00b9", "COM\u00b2", "COM\u00b3",
|
|
11
|
+
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "LPT\u00b9", "LPT\u00b2", "LPT\u00b3"
|
|
12
|
+
].freeze
|
|
13
|
+
private_constant :WINDOWS_DEVICE_NAMES
|
|
14
|
+
|
|
8
15
|
def self.binread(name, *args)
|
|
9
16
|
new(name).read(*args)
|
|
10
17
|
end
|
|
@@ -41,12 +48,24 @@ module Files
|
|
|
41
48
|
private_class_method def self.default_local_path(path)
|
|
42
49
|
name = PathUtil.normalize(path).split("/").last.to_s
|
|
43
50
|
# On Windows a colon makes the name a drive-relative path or an NTFS
|
|
44
|
-
# stream, which can write outside the working directory or onto another
|
|
45
|
-
|
|
51
|
+
# stream, which can write outside the working directory or onto another
|
|
52
|
+
# file, and a device name such as NUL writes to the device instead of a file.
|
|
53
|
+
raise InvalidParameterError.new("Bad parameter: local_path is required because #{name.inspect} is not a valid local file name") if Gem.win_platform? && (name.include?(":") || windows_device_name?(name))
|
|
46
54
|
|
|
47
55
|
name
|
|
48
56
|
end
|
|
49
57
|
|
|
58
|
+
# A bare device name is always a device. Anything after it, such as the
|
|
59
|
+
# extension in NUL.txt, makes it a device on some Windows versions and a
|
|
60
|
+
# file on others, so Windows decides those names: it resolves a device to
|
|
61
|
+
# a //./ path.
|
|
62
|
+
private_class_method def self.windows_device_name?(name)
|
|
63
|
+
base = name.split(".", 2).first.to_s.sub(/ +\z/, "")
|
|
64
|
+
return false unless WINDOWS_DEVICE_NAMES.include?(base.upcase)
|
|
65
|
+
|
|
66
|
+
base == name || ::File.absolute_path(name).start_with?("//./")
|
|
67
|
+
end
|
|
68
|
+
|
|
50
69
|
private_class_method def self.underscore_destination_path(root, id, relative_path = nil)
|
|
51
70
|
PathUtil.normalize("_", root, id.to_s, relative_path)
|
|
52
71
|
end
|
data/lib/files.com/version.rb
CHANGED
|
@@ -11,10 +11,10 @@ RSpec.describe Files::File do
|
|
|
11
11
|
described_class.download_file("folder/report:2026.txt")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
it "refuses a drive or
|
|
14
|
+
it "refuses a drive, stream, or device name on Windows" do
|
|
15
15
|
allow(Gem).to receive(:win_platform?).and_return(true)
|
|
16
16
|
|
|
17
|
-
[ "folder/C:victim.txt", "C:victim.txt", "folder/victim.txt::$DATA" ].each do |remote_path|
|
|
17
|
+
[ "folder/C:victim.txt", "C:victim.txt", "folder/victim.txt::$DATA", "folder/NUL", "folder/con", "COM1", "folder/CONIN$" ].each do |remote_path|
|
|
18
18
|
expect { described_class.download_file(remote_path) }.to raise_error(Files::InvalidParameterError)
|
|
19
19
|
end
|
|
20
20
|
end
|