From 6b71806b6a65b793737b39353848398dd6a043cf Mon Sep 17 00:00:00 2001 From: hdaniel Date: Thu, 25 Sep 2025 20:12:34 -0500 Subject: [PATCH 1/2] Handle deprecation warnings in ruby 3.4 --- lib/zxcvbn/matchers/date.rb | 4 +++- spec/scoring/entropy_spec.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/zxcvbn/matchers/date.rb b/lib/zxcvbn/matchers/date.rb index 31d1868..1a8d499 100644 --- a/lib/zxcvbn/matchers/date.rb +++ b/lib/zxcvbn/matchers/date.rb @@ -76,7 +76,9 @@ def extract_dates(token) :day => '' } for i in 0...token.length - candidate[PATTERN_CHAR_TO_SYM[pattern[i]]] << token[i] + key = PATTERN_CHAR_TO_SYM[pattern[i]] + candidate[key] = (candidate[key] || String.new) + candidate[key] << token[i] end candidate.each do |component, value| candidate[component] = value.to_i diff --git a/spec/scoring/entropy_spec.rb b/spec/scoring/entropy_spec.rb index cf84b93..c17d860 100644 --- a/spec/scoring/entropy_spec.rb +++ b/spec/scoring/entropy_spec.rb @@ -36,7 +36,7 @@ def data let(:token) { '23456' } it 'returns the correct value' do - expect(entropy.sequence_entropy(match)).to eq 5.643856189774725 + expect(entropy.sequence_entropy(match)).to be_within(1e-12).of(5.643856189774725) end end @@ -69,7 +69,7 @@ def data describe '#digits_entropy' do it 'returns the correct value' do match = Zxcvbn::Match.new(:token => '12345678') - expect(entropy.digits_entropy(match)).to eq 26.5754247590989 + expect(entropy.digits_entropy(match)).to be_within(1e-12).of(26.5754247590989) end end @@ -183,7 +183,7 @@ def data it 'should return the correct entropy' do match.graph = 'keypad' - expect(entropy.spatial_entropy(match)).to eql 9.05528243550119 + expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(9.05528243550119) end end @@ -191,7 +191,7 @@ def data it 'should return the correct entropy' do match.turns = 5 - expect(entropy.spatial_entropy(match)).to eql 21.761397858718993 + expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(21.761397858718993) end end @@ -199,7 +199,7 @@ def data it 'should return the correct entropy' do match.shiffted_count = 5 - expect(entropy.spatial_entropy(match)).to eql 9.05528243550119 + expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(9.05528243550119) end end @@ -208,9 +208,9 @@ def data match.shiffted_count = 5 match.turns = 5 - expect(entropy.spatial_entropy(match)).to eql 21.761397858718993 + expect(entropy.spatial_entropy(match)).to be_within(1e-12).of(21.761397858718993) end end end -end \ No newline at end of file +end From 39380235d63fa9d6495662ef791883a6493ff576 Mon Sep 17 00:00:00 2001 From: hdaniel Date: Thu, 25 Sep 2025 20:48:00 -0500 Subject: [PATCH 2/2] Create mutable copy --- lib/zxcvbn/matchers/date.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zxcvbn/matchers/date.rb b/lib/zxcvbn/matchers/date.rb index 1a8d499..c2b532c 100644 --- a/lib/zxcvbn/matchers/date.rb +++ b/lib/zxcvbn/matchers/date.rb @@ -77,7 +77,7 @@ def extract_dates(token) } for i in 0...token.length key = PATTERN_CHAR_TO_SYM[pattern[i]] - candidate[key] = (candidate[key] || String.new) + candidate[key] = +(candidate[key] || String.new) candidate[key] << token[i] end candidate.each do |component, value|