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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c830e118a3048b76347216008b0f720fd2bbb59e
4
- data.tar.gz: aece90372866fb87faaf591293ab5d16a78783b0
3
+ metadata.gz: dce2ab6cee5e0c117fe94303c3836757d310eeef
4
+ data.tar.gz: e409298b581bff00c3b85e957ef883e526384acf
5
5
  SHA512:
6
- metadata.gz: 08b443db602a3b6ba29e16983f8e807d2db799a81853802ce8dc67c546676384f88a98f9b8bc00d2b40006842fd45225e7ecbb6a47d39d91bf96983fa187bd6e
7
- data.tar.gz: cccd0d26230e80c9500a94988ba5e916ddb9ced50099f1aab5d0d035fe407893ac843b7f87d8217cbaf51bccb9f31dfdac26cdee4aa75a44e96e150221b25e29
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, :check_pixel_dimensions!
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 check_pixel_dimensions!(new_file)
27
- sizes = FastImage.size(new_file.path)
28
- max_sizes = max_pixel_dimensions
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
- return if !sizes || (sizes[0] <= max_sizes[0] && sizes[1] <= max_sizes[1])
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(
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module BombShelter
3
- VERSION = '0.1.0.2'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
data/lib/locale/en.yml CHANGED
@@ -2,3 +2,4 @@ en:
2
2
  errors:
3
3
  messages:
4
4
  pixel_dimensions_error: "Image size should be less than or equal to %{x_size}x%{y_size}"
5
+ not_image: "File is not an image"
data/lib/locale/fr.yml ADDED
@@ -0,0 +1,5 @@
1
+ fr:
2
+ errors:
3
+ messages:
4
+ pixel_dimensions_error: "La taille de l'image doit être inférieure ou égale à %{x_size}x%{y_size}"
5
+ not_image: "Fichier est pas une image"
data/lib/locale/ru.yml CHANGED
@@ -2,3 +2,4 @@ ru:
2
2
  errors:
3
3
  messages:
4
4
  pixel_dimensions_error: "Изображение не должно превышать размера %{x_size}x%{y_size}"
5
+ not_image: "Файл не является изображением"
data/lib/locale/tr.yml ADDED
@@ -0,0 +1,5 @@
1
+ tr:
2
+ errors:
3
+ messages:
4
+ pixel_dimensions_error: "Göürüntü boyutu %{x_size}x%{y_size} ölçüsüne eşit yada daha küçük olmalıdır"
5
+ not_image: "Dosya bir görüntü değil"
@@ -0,0 +1,5 @@
1
+ zh-TW:
2
+ errors:
3
+ messages:
4
+ pixel_dimensions_error: "圖片大小必須小於等於%{x_size}x%{y_size}"
5
+ not_image: "文件不是图像"
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.0.2
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-09-06 00:00:00.000000000 Z
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