unmagic-icon 0.2.0 → 0.2.1
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/CHANGELOG.md +14 -1
- data/lib/unmagic/icon/library/source.rb +63 -5
- data/lib/unmagic/icon/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2816013cd640fd83010c1f0ce16331c76a0cdf511d08ed0fad023625c4e3164
|
|
4
|
+
data.tar.gz: d7d034d992ccceea401a82b85173dfba4ddbeaf69d693d3394024c50ea2e5ad1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0a7a4a4bafe8628a56d08dc59c442b992599914874af08cffc5e5a2c1cdc2db33b05692a6ba9a0faf6350b5a4d99995fe51d9c41f51deedcc2bd02904dc73d6
|
|
7
|
+
data.tar.gz: b374951070dde1e5a277bce1c8b7ef2e3166b6fbaf49f3d549d235f82b36a13aaafcdefeffa5c2eeafca83017da52e37e926bc79f6eee62ca17648b6b865b0e6
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.1] - 2026-07-14
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Archives are now extracted in pure Ruby (rubyzip for zips, stdlib
|
|
14
|
+
`Gem::Package::TarReader`/`Zlib` for tarballs) instead of shelling out to
|
|
15
|
+
`unzip`/`tar`, so `unmagic:icons:install` works in minimal containers —
|
|
16
|
+
such as Rails' default slim Docker image — where those binaries aren't
|
|
17
|
+
installed. Extraction also guards against zip-slip path traversal.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Runtime dependency on `rubyzip` (>= 2.3)
|
|
21
|
+
|
|
10
22
|
## [0.2.0] - 2026-06-22
|
|
11
23
|
|
|
12
24
|
### Added
|
|
@@ -41,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
41
53
|
hooks into `assets:precompile`) and `unmagic:icons:download[library]`
|
|
42
54
|
- `Unmagic::Icon::Web`, a Rack app for browsing the configured icon libraries
|
|
43
55
|
|
|
44
|
-
[Unreleased]: https://github.com/unreasonable-magic/unmagic-icon/compare/v0.2.
|
|
56
|
+
[Unreleased]: https://github.com/unreasonable-magic/unmagic-icon/compare/v0.2.1...HEAD
|
|
57
|
+
[0.2.1]: https://github.com/unreasonable-magic/unmagic-icon/compare/v0.2.0...v0.2.1
|
|
45
58
|
[0.2.0]: https://github.com/unreasonable-magic/unmagic-icon/compare/v0.1.0...v0.2.0
|
|
46
59
|
[0.1.0]: https://github.com/unreasonable-magic/unmagic-icon/releases/tag/v0.1.0
|
|
@@ -6,7 +6,8 @@ require "json"
|
|
|
6
6
|
require "pathname"
|
|
7
7
|
require "fileutils"
|
|
8
8
|
require "tmpdir"
|
|
9
|
-
require "
|
|
9
|
+
require "zlib"
|
|
10
|
+
require "rubygems/package"
|
|
10
11
|
|
|
11
12
|
# Terminal progress is a nicety, not a requirement. The downloader runs fine
|
|
12
13
|
# (with plain output) when these sibling gems aren't installed.
|
|
@@ -211,19 +212,76 @@ module Unmagic
|
|
|
211
212
|
end
|
|
212
213
|
end
|
|
213
214
|
|
|
215
|
+
# Pure-Ruby extraction — no `unzip`/`tar` binaries required, so this
|
|
216
|
+
# works in minimal containers (e.g. Rails' default slim Docker image).
|
|
214
217
|
def extract_archive(archive_path, destination, type)
|
|
215
218
|
case type
|
|
216
219
|
when :zip
|
|
217
|
-
|
|
218
|
-
raise ExtractionError, "Failed to extract zip: #{stderr}" unless status.success?
|
|
220
|
+
extract_zip(archive_path, destination)
|
|
219
221
|
when :tgz, :tar
|
|
220
|
-
|
|
221
|
-
raise ExtractionError, "Failed to extract tar: #{stderr}" unless status.success?
|
|
222
|
+
extract_tar(archive_path, destination)
|
|
222
223
|
else
|
|
223
224
|
raise ExtractionError, "Unknown archive type: #{type}"
|
|
224
225
|
end
|
|
225
226
|
end
|
|
226
227
|
|
|
228
|
+
def extract_zip(archive_path, destination)
|
|
229
|
+
require "zip"
|
|
230
|
+
|
|
231
|
+
Zip::File.open(archive_path) do |zip|
|
|
232
|
+
zip.each do |entry|
|
|
233
|
+
path = safe_extraction_path(entry.name, destination)
|
|
234
|
+
|
|
235
|
+
if entry.directory?
|
|
236
|
+
FileUtils.mkdir_p(path)
|
|
237
|
+
elsif entry.file?
|
|
238
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
239
|
+
entry.get_input_stream do |input|
|
|
240
|
+
File.open(path, "wb") { |file| IO.copy_stream(input, file) }
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
rescue Zip::Error => e
|
|
246
|
+
raise ExtractionError, "Failed to extract zip: #{e.message}"
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
GZIP_MAGIC = "\x1f\x8b".b
|
|
250
|
+
|
|
251
|
+
def extract_tar(archive_path, destination)
|
|
252
|
+
File.open(archive_path, "rb") do |file|
|
|
253
|
+
stream = file.read(2) == GZIP_MAGIC ? Zlib::GzipReader.new(file.tap(&:rewind)) : file.tap(&:rewind)
|
|
254
|
+
|
|
255
|
+
Gem::Package::TarReader.new(stream) do |tar|
|
|
256
|
+
tar.each do |entry|
|
|
257
|
+
path = safe_extraction_path(entry.full_name, destination)
|
|
258
|
+
|
|
259
|
+
if entry.directory?
|
|
260
|
+
FileUtils.mkdir_p(path)
|
|
261
|
+
elsif entry.file?
|
|
262
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
263
|
+
File.open(path, "wb") { |output| IO.copy_stream(entry, output) }
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
rescue Zlib::Error, Gem::Package::Error => e
|
|
269
|
+
raise ExtractionError, "Failed to extract tar: #{e.message}"
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Guards against zip-slip: entries like "../../etc/passwd" must not
|
|
273
|
+
# escape the extraction directory.
|
|
274
|
+
def safe_extraction_path(entry_name, destination)
|
|
275
|
+
destination = File.expand_path(destination)
|
|
276
|
+
path = File.expand_path(entry_name, destination)
|
|
277
|
+
|
|
278
|
+
unless path == destination || path.start_with?(destination + File::SEPARATOR)
|
|
279
|
+
raise ExtractionError, "Archive entry escapes extraction directory: #{entry_name}"
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
path
|
|
283
|
+
end
|
|
284
|
+
|
|
227
285
|
def count_svgs(directory)
|
|
228
286
|
Dir.glob(File.join(directory, "**", "*.svg")).size
|
|
229
287
|
end
|
data/lib/unmagic/icon/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unmagic-icon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keith Pitt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 1.8.5
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubyzip
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.3'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.3'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rspec
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|