shrine-zip-guard 0.2.0 → 0.3.0
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 +10 -1
- data/README.md +12 -4
- data/lib/shrine/plugins/zip_guard.rb +8 -5
- data/lib/shrine-zip-guard/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: 77f0c1a42fe262acd41c72ef110fd74cadf993c0b180624ddd1d47d4a76dd1e7
|
|
4
|
+
data.tar.gz: 60996e76aa76030fabf52f525be6e6048009c2d8dc063495935d23c2b730ce4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 217ee96460de7fea169f1ce225812866a54608f98e4e4af5935a328bcc092b19450561fb9c3b314d298b3b682c31d28749eb963414594656073be3c2fe87d7cc
|
|
7
|
+
data.tar.gz: 16a011fbd591b0224420807290a1dadf694f79706107b0cc029c108d13fc46ab2c9ba23b929cbed664055fae0e85f9879e36b5ba9b3e04cf9dbef049620fa986
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [0.3.0] - 2026-08-11
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- All rescue branches in `create_derivatives` now explicitly return `{}` instead of the error messages array.
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- `rescue ZipGuard::Error` broadened to `rescue StandardError` — catches corrupt ZIP archives, other unexpected errors, and custom error subclasses like `NestedFileError`.
|
|
10
|
+
- Fallback callback (`shrine_class.opts[:zip_guard][:fallback]`) is now invoked for all rescued errors, not just `ZipGuard::Error` subclasses.
|
|
11
|
+
- Renamed internal method `handle_zip_guard_error` to `handle_error`.
|
|
12
|
+
- Renamed internal method `report_fallback` to `report_error`.
|
|
4
13
|
|
|
5
14
|
## [0.2.0] - 2026-08-06
|
|
6
15
|
|
data/README.md
CHANGED
|
@@ -75,8 +75,9 @@ class XmlUploader < Shrine
|
|
|
75
75
|
end
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
`with_zip` checks for encryption and optional required file patterns before
|
|
79
|
+
yielding the opened ZIP file. You do not need to pass `required_files` to both
|
|
80
|
+
the plugin and `with_zip`.
|
|
80
81
|
|
|
81
82
|
## Error messages
|
|
82
83
|
|
|
@@ -115,9 +116,12 @@ would become `my_uploaders/xml_uploader`.
|
|
|
115
116
|
|
|
116
117
|
## Custom fallback for unexpected errors
|
|
117
118
|
|
|
118
|
-
By default,
|
|
119
|
+
By default, any unhandled error (including corrupt ZIP archives, `StandardError`
|
|
120
|
+
subclasses not explicitly caught by the plugin) is reported to the Rails error
|
|
119
121
|
reporter (if available) and a generic `processing_failed` message is added to
|
|
120
|
-
`attacher.errors`.
|
|
122
|
+
`attacher.errors`.
|
|
123
|
+
|
|
124
|
+
You can override this with your own handler:
|
|
121
125
|
|
|
122
126
|
```ruby
|
|
123
127
|
plugin :zip_guard,
|
|
@@ -128,6 +132,10 @@ plugin :zip_guard,
|
|
|
128
132
|
}
|
|
129
133
|
```
|
|
130
134
|
|
|
135
|
+
The fallback is called for any rescued error that is not a specific
|
|
136
|
+
`EncryptedZipError` or `MissingFileError`. This includes corrupt ZIPs, custom
|
|
137
|
+
application error classes, and other unexpected errors.
|
|
138
|
+
|
|
131
139
|
## Supported versions
|
|
132
140
|
|
|
133
141
|
- Ruby >= 3.1
|
|
@@ -49,10 +49,13 @@ class Shrine
|
|
|
49
49
|
super
|
|
50
50
|
rescue ZipGuard::EncryptedZipError
|
|
51
51
|
errors << I18n.t(error_message_key("password_protected"))
|
|
52
|
+
{}
|
|
52
53
|
rescue ZipGuard::MissingFileError => e
|
|
53
54
|
errors << I18n.t(error_message_key("missing_file"), pattern: e.pattern)
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
{}
|
|
56
|
+
rescue StandardError => e
|
|
57
|
+
handle_error(e)
|
|
58
|
+
{}
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
private
|
|
@@ -74,18 +77,18 @@ class Shrine
|
|
|
74
77
|
.downcase
|
|
75
78
|
end
|
|
76
79
|
|
|
77
|
-
def
|
|
80
|
+
def handle_error(error)
|
|
78
81
|
fallback = shrine_class.opts[:zip_guard][:fallback]
|
|
79
82
|
|
|
80
83
|
if fallback
|
|
81
84
|
fallback.call(error, self)
|
|
82
85
|
else
|
|
83
|
-
|
|
86
|
+
report_error(error)
|
|
84
87
|
errors << I18n.t(error_message_key("processing_failed"))
|
|
85
88
|
end
|
|
86
89
|
end
|
|
87
90
|
|
|
88
|
-
def
|
|
91
|
+
def report_error(error)
|
|
89
92
|
return unless defined?(Rails) && Rails.respond_to?(:error) && Rails.error.respond_to?(:report)
|
|
90
93
|
|
|
91
94
|
Rails.error.report(error)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shrine-zip-guard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Dobrovodský
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: i18n
|