dragonfly 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dragonfly might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 318cb26946caa19202dc1c572f4b64014a35e08a
4
- data.tar.gz: 5ef7ed322415297775465630d3ae4bc65cfefdf9
3
+ metadata.gz: 3173e1aab6116013a04d816d1d72f2fb8240c270
4
+ data.tar.gz: e95788e8d9991755c3dade169c491aec280bb67b
5
5
  SHA512:
6
- metadata.gz: fa6361437c7a1e6e9b0d963d989d171f3fe3518d224b91666ca61a93729f0147bfad254e898231b86215e280125850ad9bcda2dc2c60b17bf6387274a29967fa
7
- data.tar.gz: 541b9b2ac910788a66af52937abb7d6674798dfdbd6de385fe5095e7fa8db6c82c5588ff6e1fe2a11bed8dcb7e00158b378fb9585aab723d39ad5d8fed764cc7
6
+ metadata.gz: 298a37955543216a2621700a1e7f80558a580073e99665ff4eac98632095db517e8140581c495eb22eaef3034b0edb7510d6b272d5baf42c06455ddceee9ec08
7
+ data.tar.gz: 8825e3ae315540658faf2874e394ebc83f43be665f01eb0be741b71687e59f54445e22163352765abcfafbf2a2b7a8d0ba513b6d9c3cc47b8cfa9746cdaf4223
@@ -6,7 +6,7 @@ rvm:
6
6
  - "2.2"
7
7
  - "2.3"
8
8
  - "2.4"
9
- - "jruby"
9
+ - "jruby-9.1.9.0"
10
10
  script: bundle exec rspec spec
11
11
  before_install:
12
12
  - gem install bundler
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ 1.1.4 (2017-12-31)
2
+ ===================
3
+ Fixes
4
+ -----
5
+ - Fixed data uris not working for long strings (reported dlibanori)
6
+ - Removed syntax warnings (swamp09)
7
+ - Correct ActiveRecord hook with `ActiveSupport.on_load` (efatsi)
8
+
1
9
  1.1.3 (2017-06-02)
2
10
  ===================
3
11
  Fixes
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  Dragonfly
2
2
  ===========
3
+
4
+ [![Build Status](https://travis-ci.org/markevans/dragonfly.svg?branch=master)](https://travis-ci.org/markevans/dragonfly)
5
+
3
6
  Hello!!
4
7
  Dragonfly is a highly customizable ruby gem for handling images and other attachments and is already in use on thousands of websites.
5
8
 
@@ -10,7 +13,7 @@ class User < ActiveRecord::Base # model
10
13
  end
11
14
  ```
12
15
  ```erb
13
- <%= image_tag @user.photo.thumb('300x200#').url # view %>
16
+ <%= image_tag @user.photo.thumb('300x200#').url if @user.photo_stored? # view %>
14
17
  ```
15
18
 
16
19
  ... or generate text images on-demand in Sinatra ...
@@ -44,7 +47,7 @@ Installation
44
47
 
45
48
  or in your Gemfile
46
49
  ```ruby
47
- gem 'dragonfly', '~> 1.1.3'
50
+ gem 'dragonfly', '~> 1.1.4'
48
51
  ```
49
52
 
50
53
  Require with
@@ -25,16 +25,16 @@ gsub_file 'app/views/photos/_form.html.erb', /^.*:image_.*$/, ''
25
25
  inject_into_file 'app/views/photos/_form.html.erb', :before => %(<div class="actions">\n) do
26
26
  %(
27
27
  <div class="field">
28
- <%= f.label :image %><br>
29
- <%= f.file_field :image %>
28
+ <%= form.label :image %><br>
29
+ <%= form.file_field :image %>
30
30
  </div>
31
31
 
32
- <%= image_tag @photo.image.thumb('100x100').url if @photo.image_uid %>
32
+ <%= image_tag @photo.image.thumb('100x100').url if @photo.image_stored? %>
33
33
  )
34
34
  end
35
35
 
36
36
  gsub_file "app/controllers/photos_controller.rb", "permit(", "permit(:image, "
37
37
 
38
38
  append_file 'app/views/photos/show.html.erb', %(
39
- <%= image_tag @photo.image.thumb('300x300').url if @photo.image_uid? %>
39
+ <%= image_tag @photo.image.thumb('300x300').url if @photo.image_stored? %>
40
40
  )
@@ -80,7 +80,7 @@ module Dragonfly
80
80
  end
81
81
 
82
82
  def update_from_data_uri
83
- mime_type, b64_data = uri.scan(/\Adata:([^;]+);base64,(.*)$/)[0]
83
+ mime_type, b64_data = uri.scan(/\Adata:([^;]+);base64,(.*)\Z/m)[0]
84
84
  if mime_type && b64_data
85
85
  data = Base64.decode64(b64_data)
86
86
  ext = app.ext_for(mime_type)
@@ -86,7 +86,7 @@ module Dragonfly
86
86
  unless Utils.blank?(string)
87
87
  begin
88
88
  dragonfly_attachments[attribute].retained_attrs = Serializer.json_b64_decode(string)
89
- rescue Serializer::BadString => e
89
+ rescue Serializer::BadString
90
90
  Dragonfly.warn("couldn't update attachment with serialized retained_#{attribute} string #{string.inspect}")
91
91
  end
92
92
  end
@@ -24,9 +24,9 @@ module Dragonfly
24
24
  Dragonfly.warn("can't handle return value from routed endpoint: #{value.inspect}")
25
25
  plain_response(500, "Server Error")
26
26
  end
27
- rescue Job::NoSHAGiven => e
27
+ rescue Job::NoSHAGiven
28
28
  plain_response(400, "You need to give a SHA parameter")
29
- rescue Job::IncorrectSHA => e
29
+ rescue Job::IncorrectSHA
30
30
  plain_response(400, "The SHA parameter you gave is incorrect")
31
31
  end
32
32
 
@@ -28,11 +28,11 @@ module Dragonfly
28
28
  attr_reader :url_format, :fetch_file_whitelist, :fetch_url_whitelist
29
29
 
30
30
  def add_to_fetch_file_whitelist(patterns)
31
- fetch_file_whitelist.push *patterns
31
+ fetch_file_whitelist.push(*patterns)
32
32
  end
33
33
 
34
34
  def add_to_fetch_url_whitelist(patterns)
35
- fetch_url_whitelist.push *patterns
35
+ fetch_url_whitelist.push(*patterns)
36
36
  end
37
37
 
38
38
  def url_format=(url_format)
@@ -24,7 +24,7 @@ module Dragonfly
24
24
 
25
25
  def initialize(url_format)
26
26
  @url_format = url_format
27
- raise BadUrlFormat, "bad url format #{url_format}" if url_format[/[\w_]:[\w_]/]
27
+ raise BadUrlFormat, "bad url format #{url_format}" if url_format[/\w:\w/]
28
28
  init_segments
29
29
  init_url_regexp
30
30
  end
@@ -43,7 +43,7 @@ module Dragonfly
43
43
  end
44
44
 
45
45
  def params_in_url
46
- @params_in_url ||= url_format.scan(/\:[\w_]+/).map{|f| f.tr(':','') }
46
+ @params_in_url ||= url_format.scan(/\:\w+/).map{|f| f.tr(':','') }
47
47
  end
48
48
 
49
49
  def url_for(params)
@@ -51,7 +51,7 @@ module Dragonfly
51
51
  url = url_format.dup
52
52
  segments.each do |seg|
53
53
  value = params[seg.param]
54
- value ? url.sub!(/:[\w_]+/, Utils.uri_escape_segment(value.to_s)) : url.sub!(/.:[\w_]+/, '')
54
+ value ? url.sub!(/:\w+/, Utils.uri_escape_segment(value.to_s)) : url.sub!(/.:\w+/, '')
55
55
  params.delete(seg.param)
56
56
  end
57
57
  url << "?#{Rack::Utils.build_query(params)}" if params.any?
@@ -62,7 +62,7 @@ module Dragonfly
62
62
 
63
63
  def init_segments
64
64
  @segments = []
65
- url_format.scan(/([^\w_]):([\w_]+)/).each do |seperator, param|
65
+ url_format.scan(/([^\w]):(\w+)/).each do |seperator, param|
66
66
  segments << Segment.new(
67
67
  param,
68
68
  seperator,
@@ -73,7 +73,7 @@ module Dragonfly
73
73
 
74
74
  def init_url_regexp
75
75
  i = -1
76
- regexp_string = url_format.gsub(/[^\w_]:[\w_]+/) do
76
+ regexp_string = url_format.gsub(/[^\w]:\w+/) do
77
77
  i += 1
78
78
  segments[i].regexp_string
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module Dragonfly
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.4'
3
3
  end
@@ -20,7 +20,7 @@ Dragonfly.logger = Rails.logger
20
20
  Rails.application.middleware.use Dragonfly::Middleware
21
21
 
22
22
  # Add model functionality
23
- if defined?(ActiveRecord::Base)
24
- ActiveRecord::Base.extend Dragonfly::Model
25
- ActiveRecord::Base.extend Dragonfly::Model::Validations
23
+ ActiveSupport.on_load(:active_record) do
24
+ extend Dragonfly::Model
25
+ extend Dragonfly::Model::Validations
26
26
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'base64'
2
3
 
3
4
  describe Dragonfly::Job::FetchUrl do
4
5
 
@@ -162,6 +163,18 @@ describe Dragonfly::Job::FetchUrl do
162
163
  job.ext.should == 'txt'
163
164
  end
164
165
 
166
+ it "accepts long base64 encoded data uris with newline" do
167
+ str = 'hello' * 10
168
+ job.fetch_url!("data:text/plain;base64,#{Base64.encode64(str)}")
169
+ job.data.should == str
170
+ end
171
+
172
+ it "accepts long base64 encoded data uris without newline" do
173
+ str = 'hello' * 10
174
+ job.fetch_url!("data:text/plain;base64,#{Base64.strict_encode64(str)}")
175
+ job.data.should == str
176
+ end
177
+
165
178
  it "doesn't accept other data uris" do
166
179
  expect {
167
180
  job.fetch_url!("data:text/html;charset=utf-8,<stuff />").apply
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack