rucaptcha 2.4.0 → 2.5.4

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
  SHA256:
3
- metadata.gz: dedcdb1109660abdd7154eba8afa5aa4b22a1ce0093b61d018b30de0c7c00367
4
- data.tar.gz: af218e451a34fd7a11a934c2a6d84f62a8c03342d87c9e7e4dc1534c79a2e07d
3
+ metadata.gz: 865e51c997ad77d19192b1da3cef9786d7dc2178ebc4528db6e281ce8d4d47e9
4
+ data.tar.gz: e1b03e54771aabc0ee2b10497b4a1f7215f2e1273908e00feb63456a30787743
5
5
  SHA512:
6
- metadata.gz: d29ad3b367a5dd326a9a3eb390a11b3dbcaf557d2520f68b7a244df3029e13e4ae878ea097ccde98ebcf3e7990402d679fde3082c3bf34b9d266d39f228d9174
7
- data.tar.gz: 0b10c69dbe3f77210f4fa450f3fc9c86721d26a6656980660de3051193e9a8617c5d6b38d747fa35196bf768ecbb24db37dc5fd369cd6d364ff9f853710c7a76
6
+ metadata.gz: 1b6cee07b419390aa91c99708f1d788f2507d0e87b4d729ed08a6d664bf527d6358bd5a6187ce29e2da1f05e95778dcb53fc07f749399564802766b40dd1f6b7
7
+ data.tar.gz: d48d9cb0ff756ec16b6121314e5f13c85c4051d17cc11d049f5f246f7231db6fea9f335724fe6c67106b9f38d09ea4403aebeb853356c2b602802f01885c7378
@@ -1,72 +1,110 @@
1
- 2.4.0
2
- -------
1
+ ## 2.5.4
2
+
3
+ - Fix: rucaptcha input maxlength attribute with config value.
4
+
5
+ 2.5.3
6
+
7
+ ---
8
+
9
+ - Fix session invalid warning, only for development env;
10
+
11
+ 2.5.2
12
+
13
+ ---
14
+
15
+ - Fix session.id error with upgrade Rails 6.0.2.1 or Rack 2.0.8 (#84)
16
+
17
+ 2.5.1
18
+
19
+ ---
20
+
21
+ - Fix invalid module name error. (#78)
22
+
23
+ 2.5.0
24
+
25
+ ---
26
+
27
+ - Support click captcha image to refresh new one by default.
28
+ - Use simple tag helper generate captcha img html, for avoid asset_host (#73).
29
+
30
+ 2.4.0
31
+
32
+ ---
3
33
 
4
34
  - Add skip_cache_store_check configuration. (#63)
5
35
  - Fix for generate captcha with relative path, not url. (#58)
6
36
 
7
- 2.3.2
8
- -------
37
+ 2.3.2
38
+
39
+ ---
9
40
 
10
41
  - Change Yellow and Green colors to Pink and Deep Purple to pass WCAG 2.0's contrast test. (#70)
11
42
 
12
- 2.3.1
13
- -------
43
+ 2.3.1
44
+
45
+ ---
14
46
 
15
47
  - Fix #67 a y chars will invalid error (only in 2.3.0).
16
48
 
17
- 2.3.0
18
- -------
49
+ 2.3.0
50
+
51
+ ---
19
52
 
20
53
  - Add `config.outline` for use outline style.
21
54
  - Reduce colors down to 5 (red, blue, green, yellow and black).
22
55
 
23
- 2.2.0
24
- -----
56
+ 2.2.0
57
+
58
+ ---
25
59
 
26
60
  - Add option `config.length` for support change number chars. (#57)
27
61
  - Add option `config.strikethrough` for enable or disable strikethrough. (#57)
28
62
 
29
- 2.1.3
30
- -----
63
+ 2.1.3
64
+
65
+ ---
31
66
 
32
67
  - Windows support fixed with `send_data` method. (#45)
33
68
 
34
- 2.1.2
35
- -----
69
+ 2.1.2
70
+
71
+ ---
36
72
 
37
73
  - Do not change captcha when `HEAD /rucaptcha`.
38
74
 
39
- 2.1.1
40
- -----
75
+ 2.1.1
76
+
77
+ ---
41
78
 
42
79
  - Mount engine use `prepend` method to get high priority in config/routes.rb.
43
80
 
44
- 2.1.0
45
- -----
81
+ 2.1.0
82
+
83
+ ---
46
84
 
47
85
  - Mount Router by default, not need config now.
48
86
 
49
87
  > IMPORTANT: Wen you upgrade this version, you need remove `mount RuCaptcha::Engine` line from your `config/routes.rb`
88
+
50
89
  - Default use [:file_store, 'tmp/cache/rucaptcha/session'] as RuCaptcha.config.cache_store, now it can work without any configurations.
51
90
 
52
91
  > NOTE: But you still need care about `config.cache_store` to setup on a right way.
53
92
 
54
-
55
-
56
- 2.0.3
57
- -----
93
+ ## 2.0.3
58
94
 
59
95
  - Use `ActiveSupport.on_load` to extend ActionController and ActionView.
60
96
 
61
- 2.0.1
62
- -----
97
+ 2.0.1
98
+
99
+ ---
63
100
 
64
101
  - Fix `/rucaptcha` path issue when `config.action_controller.asset_host` has setup with CDN url.
65
102
 
66
- 2.0.0
67
- -----
103
+ 2.0.0
104
+
105
+ ---
68
106
 
69
- *Break Changes!*
107
+ _Break Changes!_
70
108
 
71
109
  WARNING!: This version have so many break changes!
72
110
 
@@ -75,29 +113,34 @@ WARNING!: This version have so many break changes!
75
113
  - Remove `len`, `font_size`, `cache_limit` config key, no support now.
76
114
  - Output `GIF` format.
77
115
 
78
- 1.2.0
79
- -----
116
+ 1.2.0
117
+
118
+ ---
80
119
 
81
120
  - Add an `:keep_session` option for `verify_rucaptcha?` method to giva a way for let you keep session on verify, if true, RuCaptcha will not delete the captcha code session after validation.
82
121
 
83
- 1.1.4
84
- -----
122
+ 1.1.4
123
+
124
+ ---
85
125
 
86
126
  - Fix #35 just give a warning message if not setup a right cache_store, only raise on :null_store.
87
127
 
88
- 1.1.2
89
- -----
128
+ 1.1.2
129
+
130
+ ---
90
131
 
91
132
  - Fix #34 rucaptcha.root_url -> root_path, to avoid generate a http url in a https application.
92
133
  - Fix spec to require Ruby 2.0.0, because there have a `Module#prepend` method called.
93
134
 
94
- 1.1.1
95
- -----
135
+ 1.1.1
136
+
137
+ ---
96
138
 
97
139
  - Remove inspect log on verify_rucaptcha
98
140
 
99
- 1.1.0
100
- -----
141
+ 1.1.0
142
+
143
+ ---
101
144
 
102
145
  - Add `cache_store` config key to setup a cache store location for RuCaptcha.
103
146
  - Store captcha in custom cache store.
@@ -106,116 +149,136 @@ WARNING!: This version have so many break changes!
106
149
 
107
150
  - Fix Session replay secure issue that when Rails application use CookieStore.
108
151
 
109
- 1.0.0
110
- -----
152
+ 1.0.0
153
+
154
+ ---
111
155
 
112
156
  - Adjust to avoid lighter colors.
113
157
  - Avoid continuous chars have same color.
114
158
  - Use same color for each chars in :black_white mode.
115
159
 
116
- 0.5.1
117
- -----
160
+ 0.5.1
161
+
162
+ ---
118
163
 
119
164
  - Make sure it will render image when ImageMagick stderr have warning messages. (#26)
120
165
 
121
- 0.5.0
122
- -----
166
+ 0.5.0
167
+
168
+ ---
123
169
 
124
170
  - Fix cache with Rails 5.
125
171
 
126
- 0.4.5
127
- -----
172
+ 0.4.5
173
+
174
+ ---
128
175
 
129
176
  - Removed `posix-spawn` dependency, used open3 instead (core funciontality), JRuby compatible (#24)
130
177
 
131
- 0.4.4
132
- -----
178
+ 0.4.4
179
+
180
+ ---
133
181
 
134
182
  - Remove deprecated `width`, `height` config.
135
183
  - Delete session key after verify (#23).
136
184
  - Lighter text color, improve style.
137
185
 
138
- 0.4.2
139
- -----
186
+ 0.4.2
187
+
188
+ ---
140
189
 
141
190
  - Fix NoMethodError bug when params[:_rucaptha] is nil.
142
191
 
143
- 0.4.1
144
- -----
192
+ 0.4.1
193
+
194
+ ---
145
195
 
146
196
  - Add error message to resource when captcha code expired.
147
197
 
148
- 0.4.0
149
- -----
198
+ 0.4.0
199
+
200
+ ---
150
201
 
151
202
  - Add `config.colorize` option, to allow use black text theme.
152
203
 
153
- 0.3.3
154
- -----
204
+ 0.3.3
205
+
206
+ ---
155
207
 
156
208
  - Add `config.expires_in` to allow change captcha code expire time.
157
209
 
158
- 0.3.2.1
159
- -------
210
+ 0.3.2.1
211
+
212
+ ---
160
213
 
161
214
  - Add Windows development env support.
162
215
 
163
- 0.3.2
164
- -----
216
+ 0.3.2
217
+
218
+ ---
165
219
 
166
220
  - Make better render positions;
167
221
  - Trim blank space.
168
222
 
169
- 0.3.1
170
- -----
223
+ 0.3.1
224
+
225
+ ---
171
226
 
172
227
  - More complex Image render: compact text, strong lines, +/-5 rotate...
173
228
  - [DEPRECATION] config.width, config.height removed, use config.font_size.
174
229
  - Fix the render position in difference font sizes.
175
230
  - Fix input field type, and disable autocorrect, autocapitalize, and limit maxlength with char length;
176
231
 
177
- 0.2.5
178
- -----
232
+ 0.2.5
233
+
234
+ ---
179
235
 
180
236
  - Add `session[:_rucaptcha]` expire time, for protect Rails CookieSession Replay Attack.
181
237
  - Captcha input field disable autocomplete, and set field type as `email` for shown correct keyboard on mobile view.
182
238
 
183
- 0.2.3
184
- -----
239
+ 0.2.3
240
+
241
+ ---
185
242
 
186
243
  - It will raise error when call ImageMagick failed.
187
244
 
188
- 0.2.2
189
- -----
245
+ 0.2.2
246
+
247
+ ---
190
248
 
191
249
  - Added locale for pt-BR language; @ramirovjr
192
250
 
193
- 0.2.1
194
- -----
251
+ 0.2.1
252
+
253
+ ---
195
254
 
196
255
  - Fix issue when cache dir not exist.
197
256
 
198
- 0.2.0
199
- -----
257
+ 0.2.0
258
+
259
+ ---
200
260
 
201
261
  - Added file cache, can setup how many images you want generate by `config.cache_limit`,
202
262
  RuCaptcha will use cache for next requests.
203
263
  When you restart Rails processes it will generate new again and clean the old caches.
204
264
 
205
- 0.1.4
206
- -----
265
+ 0.1.4
266
+
267
+ ---
207
268
 
208
269
  - Fix `verify_rucaptcha?` logic in somecase.
209
270
  - Locales fixed.
210
271
 
211
- 0.1.3
212
- -----
272
+ 0.1.3
273
+
274
+ ---
213
275
 
214
276
  - `zh-TW` translate file fixed.
215
277
  - Use xxx_url to fix bad captcha URL for `config.action_controller.asset_host` enabled case.
216
278
 
217
- 0.1.2
218
- -----
279
+ 0.1.2
280
+
281
+ ---
219
282
 
220
283
  - No case sensitive;
221
284
  - Export config.implode;
@@ -223,12 +286,14 @@ WARNING!: This version have so many break changes!
223
286
  - Don't generate chars in 'l,o,0,1'.
224
287
  - Render lower case chars on image.
225
288
 
226
- 0.1.1
227
- -----
289
+ 0.1.1
290
+
291
+ ---
228
292
 
229
293
  - Include default validation I18n messages (en, zh-CN, zh-TW).
230
294
 
231
- 0.1.0
232
- -----
295
+ 0.1.0
296
+
297
+ ---
233
298
 
234
299
  - First release.
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # RuCaptcha
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rucaptcha.svg)](https://badge.fury.io/rb/rucaptcha)
4
- [![Build Status](https://travis-ci.org/huacnlee/rucaptcha.svg)](https://travis-ci.org/huacnlee/rucaptcha)
4
+ [![build](https://github.com/huacnlee/rucaptcha/workflows/build/badge.svg)](https://github.com/huacnlee/rucaptcha/actions?query=workflow%3Abuild)
5
5
 
6
6
  This is a Captcha gem for Rails Applications which generates captcha image by C code.
7
7
 
8
+ > NOTE: According to the use of Ruby China, the verification code looks like has a lower than 5% probability of being parsed by OCR and the verification code is cracked. It is recommended that you use the IP rate limit to enhance the protection.
9
+ > NOTE: 以 Ruby China 的使用来看,验证码似乎有低于 5% 的概率被 OCR 读取解析导致验证码被破解(我们从日志分析绝大多数是成功的,但偶尔一个成功,配合大量机器攻击,导致注册了很多的垃圾账号),建议你额外配合 IP 频率限制的功能来加强保护。
10
+
8
11
  [中文介绍和使用说明](https://ruby-china.org/topics/27832)
9
12
 
10
13
  ## Example
@@ -47,7 +50,7 @@ RuCaptcha.configure do
47
50
  # self.length = 5
48
51
  # enable/disable Strikethrough.
49
52
  # self.strikethrough = true
50
- # enable/disable Outline style, for hard mode
53
+ # enable/disable Outline style
51
54
  # self.outline = false
52
55
  end
53
56
  ```
@@ -61,6 +64,7 @@ RuCaptcha 没有使用 Rails Session 来存储验证码信息,因为 Rails 的
61
64
  所以,我建议大家使用的时候,配置上 `cache_store` (详见 [Rails Guides 缓存配置部分](https://ruby-china.github.io/rails-guides/caching_with_rails.html#%E9%85%8D%E7%BD%AE)的文档)到一个 Memcached 或 Redis,这才是最佳实践。
62
65
 
63
66
  #
67
+
64
68
  (RuCaptha do not use Rails Session to store captcha information. As the default session is stored in Cookie in Rails, there's a [Replay attack](https://en.wikipedia.org/wiki/Replay_attack) bug which may causes capthcha being destroyed if we store captcha in Rails Session.
65
69
 
66
70
  So in my design I require RuCaptcha to configure a distributed backend storage scheme, such as Memcached, Redis or other cache_store schemes which support distribution.
@@ -2,10 +2,11 @@ module RuCaptcha
2
2
  class CaptchaController < ActionController::Base
3
3
  def index
4
4
  return head :ok if request.head?
5
- headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
6
- headers['Pragma'] = 'no-cache'
5
+
6
+ headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
7
+ headers["Pragma"] = "no-cache"
7
8
  data = generate_rucaptcha
8
- opts = { disposition: 'inline', type: 'image/gif' }
9
+ opts = { disposition: "inline", type: "image/gif" }
9
10
  send_data data, opts
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  en:
2
2
  rucaptcha:
3
- invalid: "Captcha invalid!"
3
+ invalid: "The captcha code is incorrect (if you can't read, you can click image to refresh it)"
@@ -1,3 +1,3 @@
1
1
  'zh-CN':
2
2
  rucaptcha:
3
- invalid: "验证码不正确"
3
+ invalid: "验证码不正确(如无法识别,可以点击刷新验证码)"
@@ -1,3 +1,3 @@
1
1
  'zh-TW':
2
2
  rucaptcha:
3
- invalid: "驗證碼不正確"
3
+ invalid: "驗證碼不正確(如無法識別,可以點擊刷新驗證碼)"
@@ -1,3 +1,3 @@
1
1
  RuCaptcha::Engine.routes.draw do
2
- root to: 'captcha#index'
2
+ root to: "captcha#index"
3
3
  end
@@ -1,2 +1,2 @@
1
- require 'mkmf'
2
- create_makefile('rucaptcha/rucaptcha')
1
+ require "mkmf"
2
+ create_makefile("rucaptcha/rucaptcha")
@@ -1,19 +1,20 @@
1
- require 'rails'
2
- require 'action_controller'
3
- require 'active_support/all'
4
- require 'rucaptcha/rucaptcha'
5
- require 'rucaptcha/version'
6
- require 'rucaptcha/configuration'
7
- require 'rucaptcha/controller_helpers'
8
- require 'rucaptcha/view_helpers'
9
- require 'rucaptcha/cache'
10
- require 'rucaptcha/engine'
11
- require 'rucaptcha/errors/configuration'
1
+ require "rails"
2
+ require "action_controller"
3
+ require "active_support/all"
4
+ require "rucaptcha/rucaptcha"
5
+ require "rucaptcha/version"
6
+ require "rucaptcha/configuration"
7
+ require "rucaptcha/controller_helpers"
8
+ require "rucaptcha/view_helpers"
9
+ require "rucaptcha/cache"
10
+ require "rucaptcha/engine"
11
+ require "rucaptcha/errors/configuration"
12
12
 
13
13
  module RuCaptcha
14
14
  class << self
15
15
  def config
16
16
  return @config if defined?(@config)
17
+
17
18
  @config = Configuration.new
18
19
  @config.style = :colorful
19
20
  @config.length = 5
@@ -22,11 +23,11 @@ module RuCaptcha
22
23
  @config.expires_in = 2.minutes
23
24
  @config.skip_cache_store_check = false
24
25
 
25
- if Rails.application
26
- @config.cache_store = Rails.application.config.cache_store
27
- else
28
- @config.cache_store = :mem_cache_store
29
- end
26
+ @config.cache_store = if Rails.application
27
+ Rails.application.config.cache_store
28
+ else
29
+ :mem_cache_store
30
+ end
30
31
  @config.cache_store
31
32
  @config
32
33
  end
@@ -35,24 +36,22 @@ module RuCaptcha
35
36
  config.instance_exec(&block)
36
37
  end
37
38
 
38
- def generate()
39
+ def generate
39
40
  style = config.style == :colorful ? 1 : 0
40
41
  length = config.length
41
42
 
42
- unless length.in?(3..7)
43
- raise Rucaptcha::Errors::Configuration, 'length config error, value must in 3..7'
44
- end
43
+ raise RuCaptcha::Errors::Configuration, "length config error, value must in 3..7" unless length.in?(3..7)
45
44
 
46
45
  strikethrough = config.strikethrough ? 1 : 0
47
46
  outline = config.outline ? 1 : 0
48
- self.create(style, length, strikethrough, outline)
47
+ create(style, length, strikethrough, outline)
49
48
  end
50
49
 
51
50
  def check_cache_store!
52
51
  cache_store = RuCaptcha.config.cache_store
53
52
  store_name = cache_store.is_a?(Array) ? cache_store.first : cache_store
54
- if [:memory_store, :null_store, :file_store].include?(store_name)
55
- RuCaptcha.config.cache_store = [:file_store, Rails.root.join('tmp/cache/rucaptcha/session')]
53
+ if %i[memory_store null_store file_store].include?(store_name)
54
+ RuCaptcha.config.cache_store = [:file_store, Rails.root.join("tmp/cache/rucaptcha/session")]
56
55
 
57
56
  puts "
58
57
 
@@ -72,7 +71,7 @@ module RuCaptcha
72
71
  end
73
72
 
74
73
  ActiveSupport.on_load(:action_controller) do
75
- ActionController::Base.send :include, RuCaptcha::ControllerHelpers
74
+ ActionController::Base.include RuCaptcha::ControllerHelpers
76
75
  end
77
76
 
78
77
  ActiveSupport.on_load(:action_view) do
@@ -1,9 +1,10 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
 
3
3
  module RuCaptcha
4
4
  class << self
5
5
  def cache
6
6
  return @cache if defined? @cache
7
+
7
8
  @cache = ActiveSupport::Cache.lookup_store(RuCaptcha.config.cache_store)
8
9
  @cache
9
10
  end
@@ -10,12 +10,16 @@ module RuCaptcha
10
10
  def rucaptcha_sesion_key_key
11
11
  session_id = session.respond_to?(:id) ? session.id : session[:session_id]
12
12
  warning_when_session_invalid if session_id.blank?
13
- ['rucaptcha-session', session_id].join(':')
13
+
14
+ # With https://github.com/rack/rack/commit/7fecaee81f59926b6e1913511c90650e76673b38
15
+ # to protected session_id into secret
16
+ session_id_digest = Digest::SHA256.hexdigest(session_id.inspect)
17
+ ["rucaptcha-session", session_id_digest].join(":")
14
18
  end
15
19
 
16
20
  # Generate a new Captcha
17
21
  def generate_rucaptcha
18
- res = RuCaptcha.generate()
22
+ res = RuCaptcha.generate
19
23
  session_val = {
20
24
  code: res[0],
21
25
  time: Time.now.to_i
@@ -39,7 +43,7 @@ module RuCaptcha
39
43
  # verify_rucaptcha?(nil, keep_session: true)
40
44
  # verify_rucaptcha?(nil, captcha: params[:user][:captcha])
41
45
  #
42
- def verify_rucaptcha?(resource = nil, opts = {})
46
+ def verify_rucaptcha?(_resource = nil, opts = {})
43
47
  opts ||= {}
44
48
 
45
49
  store_info = RuCaptcha.cache.read(rucaptcha_sesion_key_key)
@@ -47,24 +51,16 @@ module RuCaptcha
47
51
  RuCaptcha.cache.delete(rucaptcha_sesion_key_key) unless opts[:keep_session]
48
52
 
49
53
  # Make sure session exist
50
- if store_info.blank?
51
- return add_rucaptcha_validation_error
52
- end
54
+ return add_rucaptcha_validation_error if store_info.blank?
53
55
 
54
56
  # Make sure not expire
55
- if (Time.now.to_i - store_info[:time]) > RuCaptcha.config.expires_in
56
- return add_rucaptcha_validation_error
57
- end
57
+ return add_rucaptcha_validation_error if (Time.now.to_i - store_info[:time]) > RuCaptcha.config.expires_in
58
58
 
59
59
  # Make sure parama have captcha
60
- captcha = (opts[:captcha] || params[:_rucaptcha] || '').downcase.strip
61
- if captcha.blank?
62
- return add_rucaptcha_validation_error
63
- end
60
+ captcha = (opts[:captcha] || params[:_rucaptcha] || "").downcase.strip
61
+ return add_rucaptcha_validation_error if captcha.blank?
64
62
 
65
- if captcha != store_info[:code]
66
- return add_rucaptcha_validation_error
67
- end
63
+ return add_rucaptcha_validation_error if captcha != store_info[:code]
68
64
 
69
65
  true
70
66
  end
@@ -73,12 +69,14 @@ module RuCaptcha
73
69
 
74
70
  def add_rucaptcha_validation_error
75
71
  if defined?(resource) && resource && resource.respond_to?(:errors)
76
- resource.errors.add(:base, t('rucaptcha.invalid'))
72
+ resource.errors.add(:base, t("rucaptcha.invalid"))
77
73
  end
78
74
  false
79
75
  end
80
76
 
81
77
  def warning_when_session_invalid
78
+ return unless Rails.env.development?
79
+
82
80
  Rails.logger.warn "
83
81
  WARNING! The session.id is blank, RuCaptcha can't work properly, please keep session available.
84
82
  More details about this: https://github.com/huacnlee/rucaptcha/pull/66
@@ -2,11 +2,11 @@ module RuCaptcha
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace RuCaptcha
4
4
 
5
- initializer 'rucaptcha.init' do |app|
5
+ initializer "rucaptcha.init" do |app|
6
6
  # https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_dispatch/routing/route_set.rb#L268
7
7
  # `app.routes.prepend` start from Rails 3.2 - 5.0
8
8
  app.routes.prepend do
9
- mount RuCaptcha::Engine => '/rucaptcha'
9
+ mount RuCaptcha::Engine => "/rucaptcha"
10
10
  end
11
11
 
12
12
  RuCaptcha.check_cache_store! unless RuCaptcha.config.skip_cache_store_check
@@ -1,4 +1,4 @@
1
- module Rucaptcha
1
+ module RuCaptcha
2
2
  module Errors
3
3
  class Configuration < StandardError; end
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '2.4.0'
2
+ VERSION = "2.5.4"
3
3
  end
@@ -1,19 +1,21 @@
1
1
  module RuCaptcha
2
2
  module ViewHelpers
3
3
  def rucaptcha_input_tag(opts = {})
4
- opts[:name] = '_rucaptcha'
5
- opts[:type] = 'text'
6
- opts[:autocorrect] = 'off'
7
- opts[:autocapitalize] = 'off'
8
- opts[:pattern] = '[a-zA-Z]*'
9
- opts[:autocomplete] = 'off'
10
- opts[:maxlength] ||= 5
4
+ opts[:name] = "_rucaptcha"
5
+ opts[:type] = "text"
6
+ opts[:autocorrect] = "off"
7
+ opts[:autocapitalize] = "off"
8
+ opts[:pattern] = "[a-zA-Z]*"
9
+ opts[:autocomplete] = "off"
10
+ opts[:maxlength] = RuCaptcha.config.length
11
11
  tag(:input, opts)
12
12
  end
13
13
 
14
14
  def rucaptcha_image_tag(opts = {})
15
- opts[:class] = opts[:class] || 'rucaptcha-image'
16
- image_tag(ru_captcha.root_path, opts)
15
+ opts[:class] = opts[:class] || "rucaptcha-image"
16
+ opts[:src] = ru_captcha.root_path
17
+ opts[:onclick] = "this.src = '#{ru_captcha.root_path}?t=' + Date.now();"
18
+ tag(:img, opts)
17
19
  end
18
20
  end
19
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1'
41
- description:
41
+ description:
42
42
  email: huacnlee@gmail.com
43
43
  executables: []
44
44
  extensions:
@@ -69,7 +69,7 @@ homepage: https://github.com/huacnlee/rucaptcha
69
69
  licenses:
70
70
  - MIT
71
71
  metadata: {}
72
- post_install_message:
72
+ post_install_message:
73
73
  rdoc_options: []
74
74
  require_paths:
75
75
  - lib
@@ -84,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.0.1
88
- signing_key:
87
+ rubygems_version: 3.1.4
88
+ signing_key:
89
89
  specification_version: 4
90
90
  summary: This is a Captcha gem for Rails Applications. It drawing captcha image with
91
91
  C code so it no dependencies.