Skip to content

Malformed JSON throws undocumented DomainException #378

Closed
@markrandall

Description

@markrandall

The decode method documents the following list of exceptions to decode:

* @throws InvalidArgumentException     Provided JWT was empty
     * @throws UnexpectedValueException     Provided JWT was invalid
     * @throws SignatureInvalidException    Provided JWT was invalid because the signature verification failed
     * @throws BeforeValidException         Provided JWT is trying to be used before it's eligible as defined by 'nbf'
     * @throws BeforeValidException         Provided JWT is trying to be used before it's been created as defined by 'iat'
     * @throws ExpiredException             Provided JWT has since expired, as defined by the 'exp' claim

However, this is incomplete. Providing a malformed payload results in an undocumented DomainException which propagates up the stack from self::jsonDecode

<?php
 \Firebase\JWT\JWT::decode('thisobviouslyisnt.validbase64.encodedjson', '123');

=> DomainException

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions