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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 514874151c3eb8e360abc5dfa43ebbf2f154d2ca1d449d8594cadf2ca5d73e97
4
- data.tar.gz: 8859da940e28f21beb58521361b28afead517f5dca8187e5cabfb81fe10d35be
3
+ metadata.gz: 9b5ffc9bf0c060fee8d77fd96405cfe4a4b9a023663a28ad81a908e674ad6674
4
+ data.tar.gz: 958f628e01e816b2d27f7fccad2f0c7e14e701789093ee856316738b5b4810d6
5
5
  SHA512:
6
- metadata.gz: 738e13bd0c4f53dff85f683bf68de9e871dc727d7d8e814f3765f01459aad59c0177fd580f4b1288d60ac469c81511880c51d98bc34ed4c43875a3f1c9e63a15
7
- data.tar.gz: f579fe56b1ae81c0c94b1cf09e1cf91402fae35e3b7e9b0600032474152421a1b852db6aaa5f7d202589ec8add27da3a9b79e38f7bc0a084e748e6e4dc775052
6
+ metadata.gz: f1f835a629b92c10e4250d89db0f8717a5a6907f631a97ef90c0989b2d97875c9cffd81559872d7c025dd86c0a53e301bdd4ee9c60d745070cf4bfce8c24049e
7
+ data.tar.gz: 361b8d29ab4b9201faf4e6c87cc7bf35043915cebb4714b2c6f4424214476cef96dfe7c9707b8ffb63e7ea320dccf324ba2759b62c5344e48942647de718638e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.12.0 - 2018-08-30
2
+ * add `input` option to `invisible_recaptcha_tags`'s `ui` setting
3
+
4
+ ## 4.11.1 - 2018-08-08
5
+ * leave `tabindex` attribute alone for `invisible_recaptcha_tags`
6
+
1
7
  ## 4.11.0 - 2018-08-06
2
8
  * prefer RAILS_ENV over RACK_ENV #286
3
9
 
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
- scrolling="no" name="ReCAPTCHA"
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}>#{text}</input>\n)
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 = ''.dup
70
+ html = +''
71
71
  attributes = {}
72
- fallback_uri = ''.dup
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).to_s
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
- script_url += "?hl=#{hl}" unless hl == ""
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
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # deprecated, but let's not blow everyone up
3
4
  require 'recaptcha'
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '4.12.0'
4
+ VERSION = '4.14.0'
5
5
  end
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.12.0
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: 2018-08-30 00:00:00.000000000 Z
11
+ date: 2019-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json