File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1717- Deprecation warnings for deprecated methods and classes [ #629 ] ( https://github.com/jwt/ruby-jwt/pull/629 ) ([ @anakinj ] ( https://github.com/anakinj ) )
1818- Improved documentation for public apis [ #629 ] ( https://github.com/jwt/ruby-jwt/pull/629 ) ([ @anakinj ] ( https://github.com/anakinj ) )
1919- Use correct methods when raising error during signing/verification with EdDSA [ #633 ] ( https://github.com/jwt/ruby-jwt/pull/633 )
20+ - Fix JWT::EncodedToken behavior with empty string as token [ #640 ] ( https://github.com/jwt/ruby-jwt/pull/640 ) ([ @ragalie ] ( https://github.com/ragalie ) )
2021- Your contribution here
2122
2223## [ v2.9.3] ( https://github.com/jwt/ruby-jwt/tree/v2.9.3 ) (2024-10-03)
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ def unencoded_payload?
124124 end
125125
126126 def parse_and_decode ( segment )
127- parse ( ::JWT ::Base64 . url_decode ( segment ) )
127+ parse ( ::JWT ::Base64 . url_decode ( segment || '' ) )
128128 end
129129
130130 def parse_unencoded ( segment )
Original file line number Diff line number Diff line change 4040 expect ( token . payload ) . to eq ( { 'foo' => 'bar' } )
4141 end
4242 end
43+
44+ context 'when token is the empty string' do
45+ let ( :encoded_token ) { '' }
46+
47+ it 'raises decode error' do
48+ expect { token . payload } . to raise_error ( JWT ::DecodeError , 'Invalid segment encoding' )
49+ end
50+ end
4351 end
4452
4553 describe '#header' do
4654 it { expect ( token . header ) . to eq ( { 'alg' => 'HS256' } ) }
55+
56+ context 'when token is the empty string' do
57+ let ( :encoded_token ) { '' }
58+
59+ it 'raises decode error' do
60+ expect { token . header } . to raise_error ( JWT ::DecodeError , 'Invalid segment encoding' )
61+ end
62+ end
4763 end
4864
4965 describe '#signature' do
You can’t perform that action at this time.
0 commit comments