recaptcha 4.2.0 → 4.3.1

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
  SHA1:
3
- metadata.gz: 529e90efb6c6981d74f7f1129efbb672e441ca35
4
- data.tar.gz: 81e122d8e18de0b1cc4f63ba1651587c18f5bdb6
3
+ metadata.gz: 91a422cb91f169dd8b16d4c2aaabaf8d8501dc2f
4
+ data.tar.gz: 11a287fd4d8ef0274af222feef7c77bfbb6f2c38
5
5
  SHA512:
6
- metadata.gz: b23f3ce97fb48211958f541a105050ba160a17f6c363634bb8c4aeddf8a161e57c592c96b2fa665e89379b8c84cd9d63415ca5cba7e3ab67aa0757ccdb5d68a0
7
- data.tar.gz: 6b7828dd0be7e1317dd82f4130c1cde4a7f51c90890946a2d5ff623da3c863738eb2cad27c29d79e0821393a61792f6b64b9f0d94f892b40e8bc1855d15395ce
6
+ metadata.gz: 480304f23c3411ad9386b7eb7e99846b26ccc4667d8bec27ebdf02bbd7b398736939996118d0ed0b37753af6b1c75a77c4fd4bfa61b3b1c9a9207bd399cc4087
7
+ data.tar.gz: 3ff8277354b3b38306d80ba10f39b91bc7036eef99f8478f106656f53a97f5d5d9d29daf309b2cbb8306542d0a24ba6671e9d50bc848402075a7acdae2c18090
@@ -10,10 +10,12 @@ module Recaptcha
10
10
  raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
11
11
  end
12
12
 
13
+ noscript = options.delete(:noscript)
14
+
13
15
  html, tag_attributes, fallback_uri = Recaptcha::ClientHelper.recaptcha_components(options)
14
16
  html << %(<div #{tag_attributes}></div>\n)
15
17
 
16
- if options[:noscript] != false
18
+ if noscript != false
17
19
  html << <<-HTML
18
20
  <noscript>
19
21
  <div>
@@ -45,32 +47,37 @@ module Recaptcha
45
47
 
46
48
  # Invisible reCAPTCHA implementation
47
49
  def invisible_recaptcha_tags(options = {})
50
+ text = options.delete(:text)
48
51
  html, tag_attributes = Recaptcha::ClientHelper.recaptcha_components(options)
49
- html << %(<button type="submit" #{tag_attributes}>#{options[:text]}</button>\n)
52
+
53
+ html << %(<button type="submit" #{tag_attributes}>#{text}</button>\n)
50
54
  html.respond_to?(:html_safe) ? html.html_safe : html
51
55
  end
52
56
 
53
57
  def self.recaptcha_components(options = {})
54
- site_key = options[:site_key] || Recaptcha.configuration.site_key!
55
- script_url = Recaptcha.configuration.api_server_url
56
- script_url += "?hl=#{options[:hl]}" unless options[:hl].to_s == ""
58
+ site_key = options.delete(:site_key) || Recaptcha.configuration.site_key!
59
+ html = ""
60
+ attributes = {
61
+ class: ["g-recaptcha", options.delete(:class)].join(" ")
62
+ }
57
63
 
58
- data_attributes = [:badge, :theme, :type, :callback, :expired_callback, :size]
59
- data_attributes = options.each_with_object({}) do |(k, v), a|
60
- a[k] = v if data_attributes.include?(k)
61
- end
62
- data_attributes[:sitekey] = site_key
64
+ hl = options.delete(:hl)
65
+ script_url = Recaptcha.configuration.api_server_url
66
+ script_url += "?hl=#{hl}" unless hl.to_s == ""
67
+ html << %(<script src="#{script_url}" async defer></script>\n) unless options.delete(:script) == false
68
+ fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
63
69
 
64
- tag_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
65
- if id = options[:id]
66
- tag_attributes << %( id="#{id}")
70
+ # Pull out reCaptcha specific data attributes.
71
+ [:badge, :theme, :type, :callback, :expired_callback, :size].each do |data_attribute|
72
+ if value = options.delete(data_attribute)
73
+ attributes["data-#{data_attribute}"] = value
74
+ end
67
75
  end
68
- tag_attributes << %( class="g-recaptcha #{options[:class]}")
69
76
 
70
- html = ""
71
- html << %(<script src="#{script_url}" async defer></script>\n) if options.fetch(:script, true)
77
+ attributes["data-sitekey"] = site_key
72
78
 
73
- fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
79
+ # Append whatever that's left of options to be attributes on the tag.
80
+ tag_attributes = attributes.merge(options).map { |k, v| %(#{k}="#{v}") }.join(" ")
74
81
 
75
82
  [html, tag_attributes, fallback_uri]
76
83
  end
@@ -1,3 +1,3 @@
1
1
  module Recaptcha
2
- VERSION = "4.2.0".freeze
2
+ VERSION = "4.3.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason L Perry