Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/Default domain regex #265

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/gemspecs/latest
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.4'
spec.add_development_dependency 'rspec', '~> 3.12'
spec.add_development_dependency 'rubocop', '~> 1.50', '>= 1.50.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.17', '>= 1.17.1'
spec.add_development_dependency 'rubocop', '~> 1.54', '>= 1.54.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.18'
spec.add_development_dependency 'rubocop-rspec', '~> 2.22'
spec.add_development_dependency 'simplecov', '~> 0.22.0'
spec.add_development_dependency 'smtp_mock', '~> 1.3', '>= 1.3.4'
Expand Down
3 changes: 3 additions & 0 deletions .circleci/linter_configs/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Gemspec/RequireMFA:
Gemspec/RubyVersionGlobalsUsage:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false

# RSpec -----------------------------------------------------------------------

RSpec/ExampleLength:
Expand Down
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ checks:
plugins:
rubocop:
enabled: true
channel: rubocop-1-50
channel: rubocop-1-54
config:
file: .circleci/linter_configs/.rubocop.yml

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.9] - 2023.07.19

### Fixed

- Fixed `Truemail::RegexConstant::REGEX_DOMAIN`. Thanks [@Sybe](https://github.com/Sybe) for report.

### Updated

- Updated `Truemail::Validate::Mx#hosts_from_cname_records?`
- Updated `Truemail::Validate::Smtp#not_includes_user_not_found_errors?`
- Updated development dependencies
- Updated gemspecs
- Updated `codeclimate` config
- Updated gem version

## [3.0.8] - 2023.05.11

### Updated
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(arg_value, arg_name)
end

module RegexConstant
REGEX_DOMAIN = /[\p{L}0-9]+([-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}/i.freeze
REGEX_DOMAIN = /[\p{L}0-9]+([-.]{1}[\p{L}\p{N}\p{Pd}]*[\p{L}\p{N}]+)*\.\p{L}{2,63}/i.freeze
REGEX_SIMPLE_EMAIL_PATTERN = /\w+@\w+/.freeze
REGEX_EMAIL_PATTERN = %r{(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w\p{L}.+!~,'&%#*^`{}|\-/?=$]*)@(#{REGEX_DOMAIN})\z)}.freeze
REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/validate/mx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def a_record(hostname)

def hosts_from_cname_records?
cname_records = Truemail::Dns::Resolver.cname_records(domain, configuration: configuration)
return if cname_records.empty?
return false if cname_records.empty?
cname_records.each do |cname_record|
host = a_record(cname_record.name.to_s)
hostname = Truemail::Dns::Resolver.dns_lookup(host, configuration: configuration)
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/validate/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def success_response?
end

def not_includes_user_not_found_errors?
return unless configuration.smtp_safe_check
return false unless configuration.smtp_safe_check
result.smtp_debug.map(&:response).map(&:errors).all? do |errors|
next true unless errors.key?(:rcptto)
errors.slice(:rcptto).values.none? do |error|
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Truemail
VERSION = '3.0.8'
VERSION = '3.0.9'
end
3 changes: 3 additions & 0 deletions spec/truemail/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
expect(regex_pattern.match?('l.us')).to be(true)
expect(regex_pattern.match?('1domain.us')).to be(true)
expect(regex_pattern.match?('1-domain.us')).to be(true)
expect(regex_pattern.match?('1--domain.us')).to be(true)
expect(regex_pattern.match?('truemail---website.com')).to be(true)
expect(regex_pattern.match?('1-domain-.us')).to be(false)
end

it 'allows nested subdomains' do
Expand Down