carrierwave-base64 2.5.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/carrierwave-base64.gemspec +0 -2
- data/lib/carrierwave/base64.rb +1 -0
- data/lib/carrierwave/base64/base64_string_io.rb +3 -7
- data/lib/carrierwave/base64/exceptions.rb +5 -0
- data/lib/carrierwave/base64/version.rb +1 -1
- data/spec/base64_string_io_spec.rb +11 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb281b2683a576956173494d155b372c985499a8
|
4
|
+
data.tar.gz: e28479d1490ba1a00ce8e20a862f9636fa1f78f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f102337cef6625d4ec0ea0e281c1d4e0ff57af69d9778d0b8073e4379f1fcea9ef2212002683f92643b83b7ddd03a3bf1e8c18aec92908485a709e6beb1b1098
|
7
|
+
data.tar.gz: 7e18c8cc657eebcb475caf0b6e0c5a541ada043ebb09b5506354b49b0ae427ba5f0ba1c4055c2970ecc1080148852d77c6cc65a13df11759fe9199b33e899279
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# carrierwave-base64 changelog
|
2
2
|
|
3
|
+
## 2.6.0
|
4
|
+
|
5
|
+
- Fixed the issue with base64 string not being validated (#64, @sjdrabbani)
|
6
|
+
- Sending a base64 string with missing or unknown MIME Type will raise `Carrierwave::Base64::UnknownMimeTypeError` (@lebedev-yury)
|
7
|
+
|
3
8
|
## 2.5.3
|
4
9
|
|
5
10
|
- Fixed an incorrect deprecation warning that fired even with `file_name` option set to a Proc (#60, @frodsan)
|
data/carrierwave-base64.gemspec
CHANGED
data/lib/carrierwave/base64.rb
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
module Carrierwave
|
2
2
|
module Base64
|
3
3
|
class Base64StringIO < StringIO
|
4
|
-
class ArgumentError < StandardError; end
|
5
|
-
|
6
4
|
attr_accessor :file_extension, :file_name
|
7
5
|
|
8
6
|
def initialize(encoded_file, file_name)
|
9
7
|
description, encoded_bytes = encoded_file.split(',')
|
10
8
|
|
11
|
-
raise ArgumentError unless encoded_bytes
|
12
|
-
raise ArgumentError if encoded_bytes.eql?('(null)')
|
13
|
-
|
14
9
|
@file_name = file_name
|
15
10
|
@file_extension = get_file_extension description
|
16
|
-
bytes = ::Base64.
|
11
|
+
bytes = ::Base64.strict_decode64 encoded_bytes
|
17
12
|
|
18
13
|
super bytes
|
19
14
|
end
|
@@ -28,7 +23,8 @@ module Carrierwave
|
|
28
23
|
content_type = description.split(';base64').first
|
29
24
|
mime_type = MIME::Types[content_type].first
|
30
25
|
unless mime_type
|
31
|
-
raise
|
26
|
+
raise Carrierwave::Base64::UnknownMimeTypeError,
|
27
|
+
"Unknown MIME type: #{content_type}"
|
32
28
|
end
|
33
29
|
mime_type.preferred_extension
|
34
30
|
end
|
@@ -3,7 +3,7 @@ RSpec.describe Carrierwave::Base64::Base64StringIO do
|
|
3
3
|
image/jpeg application/pdf audio/mpeg].each do |content_type|
|
4
4
|
context "correct #{content_type} data" do
|
5
5
|
let(:data) do
|
6
|
-
"data:#{content_type};base64
|
6
|
+
"data:#{content_type};base64,VGhpcyBpcyB0ZXN0IHN0cmluZw=="
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:file_extension) do
|
@@ -36,16 +36,22 @@ RSpec.describe Carrierwave::Base64::Base64StringIO do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'invalid image data' do
|
39
|
-
it 'raises
|
39
|
+
it 'raises UnknownMimeTypeError for unknown mime types' do
|
40
40
|
expect do
|
41
41
|
described_class.new('/9j/4AAQSkZJRgABAQEASABIAADKdhH//2Q==', 'file')
|
42
|
-
end.to raise_error(Carrierwave::Base64::
|
42
|
+
end.to raise_error(Carrierwave::Base64::UnknownMimeTypeError)
|
43
43
|
end
|
44
44
|
|
45
|
-
it 'raises ArgumentError if base64 data
|
45
|
+
it 'raises ArgumentError if base64 data equals to (null)' do
|
46
46
|
expect do
|
47
47
|
described_class.new('data:image/jpeg;base64,(null)', 'file')
|
48
|
-
end.to raise_error(
|
48
|
+
end.to raise_error(ArgumentError, 'invalid base64')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises ArgumentError if base64 data contains white space' do
|
52
|
+
expect do
|
53
|
+
described_class.new 'data:image/jpeg;base64,VGhpcyBpc yB0Z==', 'file'
|
54
|
+
end.to raise_error(ArgumentError, 'invalid base64')
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-base64
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Lebedev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/carrierwave/base64.rb
|
200
200
|
- lib/carrierwave/base64/adapter.rb
|
201
201
|
- lib/carrierwave/base64/base64_string_io.rb
|
202
|
+
- lib/carrierwave/base64/exceptions.rb
|
202
203
|
- lib/carrierwave/base64/version.rb
|
203
204
|
- spec/adapter_spec.rb
|
204
205
|
- spec/base64_string_io_spec.rb
|
@@ -228,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
229
|
version: '0'
|
229
230
|
requirements: []
|
230
231
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.6.
|
232
|
+
rubygems_version: 2.6.11
|
232
233
|
signing_key:
|
233
234
|
specification_version: 4
|
234
235
|
summary: Upload images encoded as base64 to carrierwave.
|