spambust 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjQ1MDVhMzViYzFiMzFmNjA1OTU3NjM0ZjllNjJhM2IzZjFlNjc5Nw==
4
+ NWU4MmQ5MTRmZGZhYjNjNTBmOTg5ZmM3MmJlMmIxZjIwMmMxN2UwMQ==
5
5
  data.tar.gz: !binary |-
6
- ZmJkZjFhNmQ1NzJjNjZjY2RjMDU5MDdlMzA3YzdiYTk2NGQ4NDM1OQ==
6
+ ZjdlODVhMjZlNDhmYzc0MTM1MzlmYWFkZDc5ZjM3ODMzY2I4MTMyYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzY3MzE3YmVlZjE3OGRjMTY3YzEzMDg3Y2VjNjI1YTM5MzYwZWEwOWJjNWYw
10
- OGM4NmIxOTc1NzNlNjE3ZDVjOGJiYjM3NzY5MGFmOTQ4M2FmNzgwNmIxZDQ4
11
- MGJiZTkzNTQ0OTFlZjY5ZGYzMzg4OTQwNjExMGNlZjczMDVkMzg=
9
+ OWI3YzUxNTViNDkzYjZmOTg2MGYzYWUzMzlmZjJlMjdjZWQyNTVhZGU0MmU4
10
+ NzU4MDEyZjdjNzNjYWZlNDEzNmNhZjhmMGQ5MTI2MDliMzc0NzhmNzg4N2Nk
11
+ NTQ4ODRmYzZmNmY1M2I4NmIwNDdkODhlNmRlZWIxYzkyY2JlYjk=
12
12
  data.tar.gz: !binary |-
13
- OThkNjc2NjY1MDBjZjVhZmJkNDNhYzNmYTQ1Y2M4MjE4OTVkOWZhNzVhNmE2
14
- MjdiYTJhYWViZjJmODQ5NWNlNWQwZmU2MWNjZWViZTM2N2VjYTEzMjQyM2Ux
15
- OGFmNTcxZTI1Mzk3NmY5MjgxMGE3MTM5MDA1YjA0YWJkZDZkZDY=
13
+ Mjc5YjZiZGNjYzVmMDY0MGIwNzEzZTUyYzM5ZDdmMGUyYjliZjlhNTRiMTgx
14
+ MWUwN2U2MDkzNjY5YWU1NDk3MmU2MjQyMGU5YzcyMmRhYWQwMDkzODVkMTI1
15
+ ODFlOWZhOGI3YjNmYjI3YTUwOWJiNjI0NWVhMzljZDczMGNjZjk=
data/README.md CHANGED
@@ -23,7 +23,7 @@ gem install spambust
23
23
  Usage
24
24
  ------
25
25
 
26
- *app.rb*
26
+ **app.rb**
27
27
 
28
28
  ``` ruby
29
29
  class TestApp < Sinatra::Base
@@ -48,11 +48,11 @@ class TestApp < Sinatra::Base
48
48
  erb :index, :locals => { :result => result }
49
49
  end
50
50
 
51
- start_app if direct_script_execution? && ENV["environment"] != "test"
51
+ start_app if direct_script_execution?
52
52
  end
53
53
  ```
54
54
 
55
- *index.erb*
55
+ **index.erb**
56
56
 
57
57
  ``` erb
58
58
  <html>
@@ -78,11 +78,11 @@ end
78
78
  </html>
79
79
  ```
80
80
 
81
- *output*
81
+ **output**
82
82
 
83
83
  ``` html
84
84
  <input type="text" name="ee11cbb19052e40b07aac0ca060c23ee[2a034e9d9e2601c21191cca53760eaaf]" id="user-first-name" />
85
- <input type="hidden" name="user[first_name]" />
85
+ <input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[first_name]" />
86
86
  ```
87
87
 
88
88
  How does it work?
@@ -61,27 +61,27 @@ module Spambust
61
61
  # </html>
62
62
 
63
63
  module FormHelpers
64
- # Returns obfustated input tags together with its fake hidden input tags
64
+ # Returns obfustated input tags together with its fake input tags that are rendered off the screen
65
65
  #
66
66
  # Use inside your templates to generate an obfuscated input field. This is the field that the server will use.
67
- # If the server sees that fields with original names (which are hidden) are filled, the server should assume
68
- # it be be a spam. It also accepts options for input type and other CSS properties.
67
+ # If the server sees that fields with original names are filled, the server should assume it be be a spam.
68
+ # It also accepts options for input type and other CSS properties.
69
69
  #
70
70
  # input(["user", "name"])
71
- # # => <input type="text" name="#{user_md5}[#{name_md5}]" /><input type="hidden" name="user[name]" />
71
+ # # => <input type="text" name="#{user_md5}[#{name_md5}]" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" />
72
72
  #
73
73
  # input(["user", "name"], :type => "password")
74
- # # => <input type="password" name="#{user_md5}[#{name_md5}]" /><input type="hidden" name="user[name]" />
74
+ # # => <input type="password" name="#{user_md5}[#{name_md5}]" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" />
75
75
  #
76
76
  # input(["user", "name"], :id => "name", :class => "name")
77
- # # => <input type="text" name="#{user_md5}[#{name_md5}]" id="name" class="name" /><input type="hidden" name="user[name]" class="name" />
77
+ # # => <input type="text" name="#{user_md5}[#{name_md5}]" id="name" class="name" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" class="name" />
78
78
  def input(paths, options = {})
79
79
  type = options.delete(:type) || "text"
80
80
  options_without_id = options.select { |key, value| key != :id }
81
81
  others = hash_to_options(options)
82
82
  others_without_id = hash_to_options(options_without_id)
83
83
  digested_paths = paths.map { |path| Digest::MD5.hexdigest(path) }
84
- %Q(<input type="#{type}" name="#{namify digested_paths}"#{others} /><input type="hidden" name="#{namify paths}"#{others_without_id} />)
84
+ %Q(<input type="#{type}" name="#{namify digested_paths}"#{others} /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="#{namify paths}"#{others_without_id} />)
85
85
  end
86
86
 
87
87
  # Returns submit tags
@@ -1,3 +1,3 @@
1
1
  module Spambust
2
- VERSION = "0.1.2" # :nodoc:
2
+ VERSION = "0.1.3" # :nodoc:
3
3
  end
@@ -15,7 +15,7 @@ describe "test application" do
15
15
  it "contains hidden input fields" do
16
16
  get "/"
17
17
 
18
- last_response.body.must_include %Q(<input type="hidden" name="user[email]" size="40" />)
18
+ last_response.body.must_include %Q(<input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[email]" size="40" />)
19
19
  end
20
20
  end
21
21
 
@@ -16,19 +16,25 @@ describe "Bustspam::FormHelpers" do
16
16
  describe "#input" do
17
17
  describe "when type is not mentioned" do
18
18
  it "renders an input tag of type 'text'" do
19
- subject.input(["user", "name"]).must_equal %Q(<input type="text" name="#{user_md5}[#{name_md5}]" /><input type="hidden" name="user[name]" />)
19
+ subject.input(["user", "name"]).must_equal %Q(<input type="text" name="#{user_md5}[#{name_md5}]" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" />)
20
20
  end
21
21
  end
22
22
 
23
23
  describe "when type is mentioned" do
24
24
  it "renders an input tag of specified type" do
25
- subject.input(["user", "name"], :type => "password").must_equal %Q(<input type="password" name="#{user_md5}[#{name_md5}]" /><input type="hidden" name="user[name]" />)
25
+ subject.input(["user", "name"], :type => "password").must_equal %Q(<input type="password" name="#{user_md5}[#{name_md5}]" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" />)
26
26
  end
27
27
  end
28
28
 
29
29
  describe "when other options are mentioned" do
30
30
  it "renders the options" do
31
- subject.input(["user", "name"], :id => "name", :class => "name").must_equal %Q(<input type="text" name="#{user_md5}[#{name_md5}]" id="name" class="name" /><input type="hidden" name="user[name]" class="name" />)
31
+ subject.input(["user", "name"], :class => "name").must_equal %Q(<input type="text" name="#{user_md5}[#{name_md5}]" class="name" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" class="name" />)
32
+ end
33
+ end
34
+
35
+ describe "when other options include 'id'" do
36
+ it "doesn't repeat the 'id'" do
37
+ subject.input(["user", "name"], :id => "name").must_equal %Q(<input type="text" name="#{user_md5}[#{name_md5}]" id="name" /><input type="text" style="position:absolute;top:-10000px;left:-10000px;" name="user[name]" />)
32
38
  end
33
39
  end
34
40
  end
@@ -1,6 +1,15 @@
1
1
  require "rack/test"
2
2
  require "sinatra/base"
3
3
 
4
+ begin
5
+ require "simplecov"
6
+ SimpleCov.start do
7
+ add_filter "/spec|test|vendor/"
8
+ end
9
+ rescue LoadError
10
+ puts "\nPlease install simplecov to generate coverage report!\n\n"
11
+ end
12
+
4
13
  gem "minitest"
5
14
  require "minitest/autorun"
6
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spambust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chirantan Mitra
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rack-test
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: minitest
84
+ name: simplecov
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ! '>='