carrierwave-bombshelter 0.1.0.2 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carrierwave/bombshelter.rb +15 -5
- data/lib/carrierwave/bombshelter/version.rb +1 -1
- data/lib/locale/en.yml +1 -0
- data/lib/locale/fr.yml +5 -0
- data/lib/locale/ru.yml +1 -0
- data/lib/locale/tr.yml +5 -0
- data/lib/locale/zh-TW.yml +5 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce2ab6cee5e0c117fe94303c3836757d310eeef
|
4
|
+
data.tar.gz: e409298b581bff00c3b85e957ef883e526384acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f6b29efd717baccd4ddd4af8a0a963170332490cc7b6673e442f84e1074838da0bc741f4cc2122b5e8c755c8ab985f6ede810bf314b02b970512b0550ba302a
|
7
|
+
data.tar.gz: 4bb42f073af153d38d2d52e6ac28dd1441f9a748a2f549d3d86ed0c15d0aaa97666324b032ad1d69592741d626ead7caa2189ebb5ab6d315f414a123456c3b0f
|
@@ -14,7 +14,7 @@ module CarrierWave
|
|
14
14
|
extend ActiveSupport::Concern
|
15
15
|
|
16
16
|
included do
|
17
|
-
before :cache, :
|
17
|
+
before :cache, :protect_from_image_bomb!
|
18
18
|
end
|
19
19
|
|
20
20
|
def max_pixel_dimensions
|
@@ -23,11 +23,21 @@ module CarrierWave
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
26
|
+
def protect_from_image_bomb!(new_file)
|
27
|
+
image = FastImage.new(new_file.path)
|
28
|
+
check_image_type!(image)
|
29
|
+
check_pixel_dimensions!(image)
|
30
|
+
end
|
31
|
+
|
32
|
+
def check_image_type!(image)
|
33
|
+
return if image.type
|
34
|
+
fail CarrierWave::IntegrityError,
|
35
|
+
I18n.translate(:'errors.messages.not_image')
|
36
|
+
end
|
29
37
|
|
30
|
-
|
38
|
+
def check_pixel_dimensions!(image)
|
39
|
+
max_sizes = max_pixel_dimensions
|
40
|
+
return if image.size[0] <= max_sizes[0] && image.size[1] <= max_sizes[1]
|
31
41
|
|
32
42
|
fail CarrierWave::IntegrityError,
|
33
43
|
I18n.translate(
|
data/lib/locale/en.yml
CHANGED
data/lib/locale/fr.yml
ADDED
data/lib/locale/ru.yml
CHANGED
data/lib/locale/tr.yml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-bombshelter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarthSim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,7 +112,10 @@ files:
|
|
112
112
|
- lib/carrierwave/bombshelter.rb
|
113
113
|
- lib/carrierwave/bombshelter/version.rb
|
114
114
|
- lib/locale/en.yml
|
115
|
+
- lib/locale/fr.yml
|
115
116
|
- lib/locale/ru.yml
|
117
|
+
- lib/locale/tr.yml
|
118
|
+
- lib/locale/zh-TW.yml
|
116
119
|
homepage: https://github.com/DarthSim/carrierwave-bombshelter
|
117
120
|
licenses:
|
118
121
|
- MIT
|