recaptcha 4.12.0 → 4.14.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 +6 -0
- data/README.md +2 -0
- data/lib/recaptcha/client_helper.rb +18 -7
- data/lib/recaptcha/rails.rb +1 -0
- data/lib/recaptcha/verify.rb +2 -1
- data/lib/recaptcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5ffc9bf0c060fee8d77fd96405cfe4a4b9a023663a28ad81a908e674ad6674
|
4
|
+
data.tar.gz: 958f628e01e816b2d27f7fccad2f0c7e14e701789093ee856316738b5b4810d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1f835a629b92c10e4250d89db0f8717a5a6907f631a97ef90c0989b2d97875c9cffd81559872d7c025dd86c0a53e301bdd4ee9c60d745070cf4bfce8c24049e
|
7
|
+
data.tar.gz: 361b8d29ab4b9201faf4e6c87cc7bf35043915cebb4714b2c6f4424214476cef96dfe7c9707b8ffb63e7ea320dccf324ba2759b62c5344e48942647de718638e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -73,6 +73,8 @@ Some of the options available:
|
|
73
73
|
| :error | Override the error code returned from the reCAPTCHA API (default `nil`)|
|
74
74
|
| :size | Specify a size (default `nil`)|
|
75
75
|
| :hl | Optional. Forces the widget to render in a specific language. Auto-detects the user's language if unspecified. (See [language codes](https://developers.google.com/recaptcha/docs/language)) |
|
76
|
+
| :onload | Optional. The name of your callback function to be executed once all the dependencies have loaded. (See [explicit rendering](https://developers.google.com/recaptcha/docs/display#explicit_render))|
|
77
|
+
| :render | Optional. Whether to render the widget explicitly. Defaults to `onload`, which will render the widget in the first g-recaptcha tag it finds. (See [explicit rendering](https://developers.google.com/recaptcha/docs/display#explicit_render))|
|
76
78
|
| :nonce | Optional. Sets nonce attribute for script. Can be generated via `SecureRandom.base64(32)`. (default `nil`)|
|
77
79
|
| :id | Specify an html id attribute (default `nil`)|
|
78
80
|
| :script | If you do not need to add a script tag by helper you can set the option to false. It's necessary when you add a script tag manualy (default `true`)|
|
@@ -25,8 +25,8 @@ module Recaptcha
|
|
25
25
|
<div style="width: 302px; height: 422px; position: absolute;">
|
26
26
|
<iframe
|
27
27
|
src="#{fallback_uri}"
|
28
|
-
|
29
|
-
style="width: 302px; height: 422px; border-style: none; border: 0;">
|
28
|
+
name="ReCAPTCHA"
|
29
|
+
style="width: 302px; height: 422px; border-style: none; border: 0; overflow: hidden;">
|
30
30
|
</iframe>
|
31
31
|
</div>
|
32
32
|
</div>
|
@@ -59,7 +59,7 @@ module Recaptcha
|
|
59
59
|
when :invisible
|
60
60
|
html << %(<div data-size="invisible" #{tag_attributes}></div>\n)
|
61
61
|
when :input
|
62
|
-
html << %(<input type="submit" #{tag_attributes}
|
62
|
+
html << %(<input type="submit" #{tag_attributes} value="#{text}"/>\n)
|
63
63
|
else
|
64
64
|
raise(RecaptchaError, "ReCAPTCHA ui `#{options[:ui]}` is not valid.")
|
65
65
|
end
|
@@ -67,9 +67,9 @@ module Recaptcha
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.recaptcha_components(options = {})
|
70
|
-
html = ''
|
70
|
+
html = +''
|
71
71
|
attributes = {}
|
72
|
-
fallback_uri = ''
|
72
|
+
fallback_uri = +''
|
73
73
|
|
74
74
|
# Since leftover options get passed directly through as tag
|
75
75
|
# attributes, we must unconditionally delete all our options
|
@@ -77,7 +77,9 @@ module Recaptcha
|
|
77
77
|
env = options.delete(:env)
|
78
78
|
class_attribute = options.delete(:class)
|
79
79
|
site_key = options.delete(:site_key)
|
80
|
-
hl = options.delete(:hl)
|
80
|
+
hl = options.delete(:hl)
|
81
|
+
onload = options.delete(:onload)
|
82
|
+
render = options.delete(:render)
|
81
83
|
nonce = options.delete(:nonce)
|
82
84
|
skip_script = (options.delete(:script) == false)
|
83
85
|
ui = options.delete(:ui)
|
@@ -93,7 +95,12 @@ module Recaptcha
|
|
93
95
|
unless Recaptcha::Verify.skip?(env)
|
94
96
|
site_key ||= Recaptcha.configuration.site_key!
|
95
97
|
script_url = Recaptcha.configuration.api_server_url
|
96
|
-
|
98
|
+
query_params = hash_to_query(
|
99
|
+
hl: hl,
|
100
|
+
onload: onload,
|
101
|
+
render: render
|
102
|
+
)
|
103
|
+
script_url += "?#{query_params}" unless query_params.empty?
|
97
104
|
nonce_attr = " nonce='#{nonce}'" if nonce
|
98
105
|
html << %(<script src="#{script_url}" async defer#{nonce_attr}></script>\n) unless skip_script
|
99
106
|
fallback_uri = %(#{script_url.chomp(".js")}/fallback?k=#{site_key})
|
@@ -142,5 +149,9 @@ module Recaptcha
|
|
142
149
|
!Recaptcha::Verify.skip?(options[:env]) &&
|
143
150
|
options[:script] != false
|
144
151
|
end
|
152
|
+
|
153
|
+
private_class_method def self.hash_to_query(hash)
|
154
|
+
hash.delete_if { |_, val| val.nil? || val.empty? }.to_a.map { |pair| pair.join('=') }.join('&')
|
155
|
+
end
|
145
156
|
end
|
146
157
|
end
|
data/lib/recaptcha/rails.rb
CHANGED
data/lib/recaptcha/verify.rb
CHANGED
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
module Recaptcha
|
6
6
|
module Verify
|
7
|
+
G_RESPONSE_LIMIT = 4000
|
7
8
|
# Your private API can be specified in the +options+ hash or preferably
|
8
9
|
# using the Configuration.
|
9
10
|
def verify_recaptcha(options = {})
|
@@ -15,7 +16,7 @@ module Recaptcha
|
|
15
16
|
recaptcha_response = options[:response] || params['g-recaptcha-response'].to_s
|
16
17
|
|
17
18
|
begin
|
18
|
-
verified = if recaptcha_response.empty?
|
19
|
+
verified = if recaptcha_response.empty? || recaptcha_response.length > G_RESPONSE_LIMIT
|
19
20
|
false
|
20
21
|
else
|
21
22
|
recaptcha_verify_via_api_call(request, recaptcha_response, options)
|
data/lib/recaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason L Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|