invisible_captcha 2.1.0 → 2.2.0

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: f15e5223696c06e82c8ab6182a4396a9e4e4bf3acd6e425296e60cc6b49cb225
4
- data.tar.gz: e35b51231012ae92b236f81eb1966a16ea3c7b02862d03977bf23478d968538d
3
+ metadata.gz: b054e8cc12c7c543111eabaa13c46e4ec94d99200bf8fb189d6d1284568f9b3a
4
+ data.tar.gz: 11c94f7e36b4c2892c9def7ab86b5fcb560005fdc0c68b5beef3971eb065950c
5
5
  SHA512:
6
- metadata.gz: ccc4299595595e513fa8f8eb472233b83fa334608b3cd4fcba3d1316b8f1819d83e7cc3d2678dce0ac954c52a4b90ecf0643424d0358cd8dd3412c4aa04ac391
7
- data.tar.gz: 1fcceba58cb21d931e6d8f7f49a3a1649230628442e18f3664a80d5ac983dbec0bc5caeeda17cacc748bfbfabce93bd189f695bc0d123d4bd2ef0d94a20cdb3e
6
+ metadata.gz: eea98bc58a674b4daa961a5fc3bb5edafbfef74034ed06364684993d96802a7bd8c169507f208b635ba24b09fc0e0b69039f964babd874e1104ae9a29c1dc2ee
7
+ data.tar.gz: 710d6bf3c780d91525dca60566db5f20f564f784e27223af0ab9342fb95d1bc507e4bdafe687cdacd60b7496f547a5f81653b6a7ebfcca0425fd2de53a13adba
@@ -12,7 +12,7 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  ruby: ["2.7", "3.0", "3.1", "3.2"]
15
- gemfile: [rails_6.0, rails_6.1, rails_7.0]
15
+ gemfile: [rails_6.0, rails_6.1, rails_7.0, rails_7.1]
16
16
  exclude:
17
17
  - ruby: "3.1"
18
18
  gemfile: rails_6.0
data/Appraisals CHANGED
@@ -1,4 +1,5 @@
1
1
  %w(
2
+ 7.1
2
3
  7.0
3
4
  6.1
4
5
  6.0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.2.0]
6
+
7
+ - Official support for Rails 7.1
8
+ - Fix flash message for `on_timestamp_spam` callback (#125)
9
+ - Fix potential error when lookup the honeypot parameter using (#128)
10
+
5
11
  ## [2.1.0]
6
12
 
7
13
  - Drop official support for EOL Rubies: 2.5 and 2.6
@@ -130,6 +136,7 @@ All notable changes to this project will be documented in this file.
130
136
 
131
137
  - First version of controller filters
132
138
 
139
+ [2.2.0]: https://github.com/markets/invisible_captcha/compare/v2.1.0...v2.2.0
133
140
  [2.1.0]: https://github.com/markets/invisible_captcha/compare/v2.0.0...v2.1.0
134
141
  [2.0.0]: https://github.com/markets/invisible_captcha/compare/v1.1.0...v2.0.0
135
142
  [1.1.0]: https://github.com/markets/invisible_captcha/compare/v1.0.1...v1.1.0
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1.0"
6
+
7
+ gemspec path: "../"
@@ -30,7 +30,8 @@ module InvisibleCaptcha
30
30
  if action = options[:on_timestamp_spam]
31
31
  send(action)
32
32
  else
33
- redirect_back(fallback_location: root_path, flash: { error: InvisibleCaptcha.timestamp_error_message })
33
+ flash[:error] = InvisibleCaptcha.timestamp_error_message
34
+ redirect_back(fallback_location: root_path)
34
35
  end
35
36
  end
36
37
 
@@ -88,7 +89,7 @@ module InvisibleCaptcha
88
89
  # If honeypot is defined for this controller-action, search for:
89
90
  # - honeypot: params[:subtitle]
90
91
  # - honeypot with scope: params[:topic][:subtitle]
91
- if params[honeypot].present? || params.dig(scope, honeypot).present?
92
+ if params[honeypot].present? || (params[scope] && params[scope][honeypot].present?)
92
93
  warn_spam("Honeypot param '#{honeypot}' was present.")
93
94
  return true
94
95
  else
@@ -98,7 +99,7 @@ module InvisibleCaptcha
98
99
  end
99
100
  else
100
101
  InvisibleCaptcha.honeypots.each do |default_honeypot|
101
- if params[default_honeypot].present? || params.dig(scope, default_honeypot).present?
102
+ if params[default_honeypot].present? || (params[scope] && params[scope][default_honeypot].present?)
102
103
  warn_spam("Honeypot param '#{scope}.#{default_honeypot}' was present.")
103
104
  return true
104
105
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InvisibleCaptcha
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
@@ -84,7 +84,7 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
84
84
  }
85
85
 
86
86
  expect(flash[:error]).not_to be_present
87
- expect(response.body).to be_present
87
+ expect(response.body).to redirect_to(new_topic_path)
88
88
 
89
89
  # Make sure session is cleared
90
90
  expect(session[:invisible_captcha_timestamp]).to be_nil
@@ -96,7 +96,7 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
96
96
  post :publish, params: { id: 1 }
97
97
 
98
98
  expect(flash[:error]).not_to be_present
99
- expect(response.body).to be_present
99
+ expect(response.body).to redirect_to(new_topic_path)
100
100
  end
101
101
  end
102
102
  end
@@ -126,13 +126,13 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
126
126
  it 'passes with no spam' do
127
127
  post :categorize, params: { topic: { title: 'foo' } }
128
128
 
129
- expect(response.body).to be_present
129
+ expect(response.body).to redirect_to(new_topic_path)
130
130
  end
131
131
 
132
132
  it 'fails with spam' do
133
133
  post :categorize, params: { topic: { "#{InvisibleCaptcha.honeypots.sample}": 'foo' } }
134
134
 
135
- expect(response.body).to be_blank
135
+ expect(response.body).not_to redirect_to(new_topic_path)
136
136
  end
137
137
  end
138
138
 
@@ -140,13 +140,13 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
140
140
  it 'passes with no spam' do
141
141
  post :categorize
142
142
 
143
- expect(response.body).to be_present
143
+ expect(response.body).to redirect_to(new_topic_path)
144
144
  end
145
145
 
146
146
  it 'fails with spam' do
147
147
  post :categorize, params: { "#{InvisibleCaptcha.honeypots.sample}": 'foo' }
148
148
 
149
- expect(response.body).to be_blank
149
+ expect(response.body).not_to redirect_to(new_topic_path)
150
150
  end
151
151
  end
152
152
 
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Dummy</title>
4
+ <title>InvisibleCaptcha Demo</title>
5
5
  <%= stylesheet_link_tag "/styles.css" %>
6
6
  <%= csrf_meta_tags %>
7
7
  <%= invisible_captcha_styles %>
@@ -24,5 +24,11 @@
24
24
  <% end %>
25
25
 
26
26
  <%= yield %>
27
+
28
+ <footer>
29
+ Running on
30
+ <b>Ruby <%= RUBY_VERSION %></b> and
31
+ <b>Rails <%= Rails.version %></b>
32
+ </footer>
27
33
  </body>
28
34
  </html>
@@ -31,6 +31,15 @@ button {
31
31
  font-size: 1em;
32
32
  }
33
33
 
34
+ footer {
35
+ position: fixed;
36
+ bottom: 0;
37
+ width: 100%;
38
+ padding: 1em 0;
39
+ font-size: 0.8em;
40
+ background-color: #ccc;
41
+ }
42
+
34
43
  .errors {
35
44
  color: darkred;
36
45
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invisible_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Anguera Insa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-12 00:00:00.000000000 Z
11
+ date: 2024-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -115,6 +115,7 @@ files:
115
115
  - gemfiles/rails_6.0.gemfile
116
116
  - gemfiles/rails_6.1.gemfile
117
117
  - gemfiles/rails_7.0.gemfile
118
+ - gemfiles/rails_7.1.gemfile
118
119
  - invisible_captcha.gemspec
119
120
  - lib/invisible_captcha.rb
120
121
  - lib/invisible_captcha/controller_ext.rb
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  - !ruby/object:Gem::Version
181
182
  version: '0'
182
183
  requirements: []
183
- rubygems_version: 3.4.6
184
+ rubygems_version: 3.4.10
184
185
  signing_key:
185
186
  specification_version: 4
186
187
  summary: Honeypot spam protection for Rails