diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd4162..86cca23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ 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). +## [2.5.2] - 2021.10.06 + +### Fixed + +- `Truemail::RegexConstant::REGEX_EMAIL_PATTERN` behaviour with double `@` in email. Thanks [@your-favorite-dev](https://github.com/your-favorite-dev) for bug report. + +### Updated + +- Updated tests +- Updated gem development dependencies +- Updated gem version + ## [2.5.1] - 2021.10.01 ### Updated diff --git a/Gemfile.lock b/Gemfile.lock index 909e491..a6755c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - truemail (2.5.1) + truemail (2.5.2) simpleidn (~> 0.2.1) GEM @@ -26,7 +26,7 @@ GEM fasterer (0.9.0) colorize (~> 0.7) ruby_parser (>= 3.14.1) - ffaker (2.19.0) + ffaker (2.20.0) hashdiff (1.0.1) iniparse (1.5.0) json (2.5.1) @@ -70,7 +70,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.22.0) + rubocop (1.22.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) @@ -119,14 +119,14 @@ DEPENDENCIES bundler-audit (~> 0.9.0.1) dns_mock (~> 1.4, >= 1.4.2) fasterer (~> 0.9.0) - ffaker (~> 2.19) + ffaker (~> 2.20) json_matchers (~> 0.11.1) overcommit (~> 0.58.0) pry-byebug (~> 3.9) rake (~> 13.0, >= 13.0.6) reek (~> 6.0, >= 6.0.6) rspec (~> 3.10) - rubocop (~> 1.22) + rubocop (~> 1.22, >= 1.22.1) rubocop-performance (~> 1.11, >= 1.11.5) rubocop-rspec (~> 2.5) simplecov (~> 0.17.1) diff --git a/lib/truemail/core.rb b/lib/truemail/core.rb index 004ea13..2ba62c0 100644 --- a/lib/truemail/core.rb +++ b/lib/truemail/core.rb @@ -20,7 +20,7 @@ def initialize(arg_value, arg_name) module RegexConstant REGEX_DOMAIN = /[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}/i.freeze - REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\W\w]*)@(#{REGEX_DOMAIN})\z)/.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 REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i.freeze diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index ff0474d..6bda452 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '2.5.1' + VERSION = '2.5.2' end diff --git a/spec/truemail/core_spec.rb b/spec/truemail/core_spec.rb index 5ccbb16..5eaf8a0 100644 --- a/spec/truemail/core_spec.rb +++ b/spec/truemail/core_spec.rb @@ -28,6 +28,8 @@ describe 'Truemail::RegexConstant::REGEX_EMAIL_PATTERN' do subject(:regex_pattern) { described_class::REGEX_EMAIL_PATTERN } + let(:special_chars) { %w[- _ . + ! ~ , ' & % # $ * / = ? ^ ` { | }] } + it 'allows from 6 to 255 chars' do expect( regex_pattern.match?(Truemail::GenerateEmailHelper.call(size: :min)) @@ -67,14 +69,24 @@ it 'allows special chars' do expect( - regex_pattern.match?(Truemail::GenerateEmailHelper.call(symbols: %w[- _ . + ! ~ , ' & % # $ * / = ? ^ ` { | }])) + regex_pattern.match?( + Truemail::GenerateEmailHelper.call(symbols: special_chars) + ) ).to be(true) end it 'not allows special chars for one char username' do expect( regex_pattern.match?( - Truemail::GenerateEmailHelper.call(size: :min, invalid_email_with: %w[- _ . + ! ~ , ' & % # $ * / = ? ^ ` { | }]) + Truemail::GenerateEmailHelper.call(size: :min, invalid_email_with: special_chars) + ) + ).to be(false) + end + + it 'not allows double @ char in email' do + expect( + regex_pattern.match?( + Truemail::GenerateEmailHelper.call(invalid_email_with: %w[@]) ) ).to be(false) end diff --git a/truemail.gemspec b/truemail.gemspec index 2c0f405..e200255 100644 --- a/truemail.gemspec +++ b/truemail.gemspec @@ -37,14 +37,14 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler-audit', '~> 0.9.0.1' spec.add_development_dependency 'dns_mock', '~> 1.4', '>= 1.4.2' spec.add_development_dependency 'fasterer', '~> 0.9.0' - spec.add_development_dependency 'ffaker', '~> 2.19' + spec.add_development_dependency 'ffaker', '~> 2.20' spec.add_development_dependency 'json_matchers', '~> 0.11.1' spec.add_development_dependency 'overcommit', '~> 0.58.0' spec.add_development_dependency 'pry-byebug', '~> 3.9' spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.6' spec.add_development_dependency 'rspec', '~> 3.10' - spec.add_development_dependency 'rubocop', '~> 1.22' + spec.add_development_dependency 'rubocop', '~> 1.22', '>= 1.22.1' spec.add_development_dependency 'rubocop-performance', '~> 1.11', '>= 1.11.5' spec.add_development_dependency 'rubocop-rspec', '~> 2.5' spec.add_development_dependency 'simplecov', '~> 0.17.1'