From b282f4e5f401eff3ba67ebee8b07e96e678c837e Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Wed, 19 Jul 2023 13:04:11 +0200 Subject: [PATCH] Bugfix/Default domain regex * Fixed Truemail::RegexConstant::REGEX_DOMAIN, updated tests * Updated Truemail::Validate::Mx#hosts_from_cname_records? * Updated Truemail::Validate::Smtp#not_includes_user_not_found_errors? * Updated development dependencies * Updated gemspecs * Updated rubocop, codeclimate config * Updated gem version, changelog --- .circleci/gemspecs/latest | 4 ++-- .circleci/linter_configs/.rubocop.yml | 3 +++ .codeclimate.yml | 2 +- CHANGELOG.md | 15 +++++++++++++++ lib/truemail/core.rb | 2 +- lib/truemail/validate/mx.rb | 2 +- lib/truemail/validate/smtp.rb | 2 +- lib/truemail/version.rb | 2 +- spec/truemail/core_spec.rb | 3 +++ 9 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.circleci/gemspecs/latest b/.circleci/gemspecs/latest index 4995e18..521d148 100644 --- a/.circleci/gemspecs/latest +++ b/.circleci/gemspecs/latest @@ -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' diff --git a/.circleci/linter_configs/.rubocop.yml b/.circleci/linter_configs/.rubocop.yml index f3a32ef..1c13781 100644 --- a/.circleci/linter_configs/.rubocop.yml +++ b/.circleci/linter_configs/.rubocop.yml @@ -99,6 +99,9 @@ Gemspec/RequireMFA: Gemspec/RubyVersionGlobalsUsage: Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false + # RSpec ----------------------------------------------------------------------- RSpec/ExampleLength: diff --git a/.codeclimate.yml b/.codeclimate.yml index 27e3760..68428b9 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -9,7 +9,7 @@ checks: plugins: rubocop: enabled: true - channel: rubocop-1-50 + channel: rubocop-1-54 config: file: .circleci/linter_configs/.rubocop.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index fb5c41f..692fdfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/truemail/core.rb b/lib/truemail/core.rb index 7130bed..9910ce5 100644 --- a/lib/truemail/core.rb +++ b/lib/truemail/core.rb @@ -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 diff --git a/lib/truemail/validate/mx.rb b/lib/truemail/validate/mx.rb index 29f070f..023bf37 100644 --- a/lib/truemail/validate/mx.rb +++ b/lib/truemail/validate/mx.rb @@ -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) diff --git a/lib/truemail/validate/smtp.rb b/lib/truemail/validate/smtp.rb index ccf677e..ddcf232 100644 --- a/lib/truemail/validate/smtp.rb +++ b/lib/truemail/validate/smtp.rb @@ -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| diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index 8b4e0bd..9fe69a0 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '3.0.8' + VERSION = '3.0.9' end diff --git a/spec/truemail/core_spec.rb b/spec/truemail/core_spec.rb index 1ad8ae4..110c817 100644 --- a/spec/truemail/core_spec.rb +++ b/spec/truemail/core_spec.rb @@ -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