DCIT / perl-Crypt-JWT

Other
54 stars 18 forks source link

encode_jwt with invalid algorithm fails with unintuitive exception #25

Closed isido closed 4 years ago

isido commented 4 years ago

When doing something like: encode_jwt( payload => 'data', alg => 'foo', key => 'secret' ) with illegal alg value fails with

Use of uninitialized value $enc in pattern match (m//) at
    /home/..../perl5/lib/perl5/Crypt/JWT.pm line 301 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

Perhaps the JWE branch in encode_jwt or _encode_jwe should croak if the parameters are missing or invalid.