spectator-validates_email 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -55,6 +55,7 @@ Most of the code were taken from Alex Dunae (dunae.ca) plugin (see http://github
55
55
 
56
56
  * Petr Blaho
57
57
  * Christian Eichhorn
58
+ * Alexander Zubkov
58
59
 
59
60
  == How to contribute
60
61
 
@@ -2,11 +2,14 @@
2
2
  # validation mechanism.
3
3
  #
4
4
  class EmailValidator < ActiveModel::EachValidator
5
+ class Encoding
6
+ class CompatibilityError < StandardError; end
7
+ end if RUBY_VERSION.to_f < 1.9
5
8
 
6
9
  LocalPartSpecialChars = Regexp.escape('!#$%&\'*-/=?+-^_`{|}~')
7
10
  LocalPartUnquoted = '(([[:alnum:]' + LocalPartSpecialChars + ']+[\.\+]+))*[[:alnum:]' + LocalPartSpecialChars + '+]+'
8
11
  LocalPartQuoted = '\"(([[:alnum:]' + LocalPartSpecialChars + '\.\+]*|(\\\\[\x00-\xFF]))*)\"'
9
- Regex = Regexp.new('^((' + LocalPartUnquoted + ')|(' + LocalPartQuoted + ')+)@(((\w+\-+[^_])|(\w+\.[^_]))*([a-z0-9-]{1,63})\.[a-z]{2,6}$)', Regexp::EXTENDED | Regexp::IGNORECASE, 'n')
12
+ Regex = Regexp.new('^((' + LocalPartUnquoted + ')|(' + LocalPartQuoted + ')+)@(((\w+\-+[^_])|(\w+\.[^_]))*([a-z0-9-]{1,63})\.[a-z]{2,6}(?:\.[a-z]{2,6})?$)', Regexp::EXTENDED | Regexp::IGNORECASE, 'n')
10
13
 
11
14
  # Validates email address.
12
15
  # If MX fallback was also requested, it will check if email is valid
@@ -44,7 +47,14 @@ class EmailValidator < ActiveModel::EachValidator
44
47
  return false
45
48
  end
46
49
 
47
- email =~ Regex and not email =~ /\.\./ and domain.length <= 255 and local.length <= 64
50
+ begin
51
+ email =~ Regex and not email =~ /\.\./ and domain.length <= 255 and local.length <= 64
52
+ rescue Encoding::CompatibilityError
53
+ # RFC 2822 and RFC 3696 don't support UTF-8 characters in email address,
54
+ # so Regexp is in ASCII-8BIT encoding, which raises this exception when
55
+ # you try email address with unicode characters in it.
56
+ return false
57
+ end
48
58
  end
49
59
 
50
60
  # Checks email is its domain is valid. Fallbacks to A record if requested.
@@ -1,3 +1,3 @@
1
1
  module ValidatesEmail
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectator-validates_email
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
4
+ prerelease:
5
+ version: 0.0.7
11
6
  platform: ruby
12
7
  authors:
13
8
  - Yury Velikanau
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-11-07 00:00:00 -07:00
13
+ date: 2011-06-14 00:00:00 -07:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
34
24
  version: 3.0.0
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 3
48
- - 0
49
- - 0
50
35
  version: 3.0.0
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 23
62
- segments:
63
- - 1
64
- - 0
65
- - 0
66
46
  version: 1.0.0
67
47
  type: :development
68
48
  version_requirements: *id003
@@ -74,11 +54,6 @@ dependencies:
74
54
  requirements:
75
55
  - - ~>
76
56
  - !ruby/object:Gem::Version
77
- hash: 15
78
- segments:
79
- - 2
80
- - 0
81
- - 0
82
57
  version: 2.0.0
83
58
  type: :development
84
59
  version_requirements: *id004
@@ -90,14 +65,20 @@ dependencies:
90
65
  requirements:
91
66
  - - ~>
92
67
  - !ruby/object:Gem::Version
93
- hash: 25
94
- segments:
95
- - 1
96
- - 3
97
- - 1
98
68
  version: 1.3.1
99
69
  type: :development
100
70
  version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 0.8.7
80
+ type: :development
81
+ version_requirements: *id006
101
82
  description: Rails 3 plugin to validate email addresses against RFC 2822 and RFC 3696
102
83
  email:
103
84
  - yury.velikanau@gmail.com
@@ -127,25 +108,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
108
  requirements:
128
109
  - - ">="
129
110
  - !ruby/object:Gem::Version
130
- hash: 3
131
- segments:
132
- - 0
133
111
  version: "0"
134
112
  required_rubygems_version: !ruby/object:Gem::Requirement
135
113
  none: false
136
114
  requirements:
137
115
  - - ">="
138
116
  - !ruby/object:Gem::Version
139
- hash: 23
140
- segments:
141
- - 1
142
- - 3
143
- - 6
144
117
  version: 1.3.6
145
118
  requirements: []
146
119
 
147
120
  rubyforge_project:
148
- rubygems_version: 1.3.7
121
+ rubygems_version: 1.5.2
149
122
  signing_key:
150
123
  specification_version: 3
151
124
  summary: Rails 3 plugin to validate email addresses