web-token / jwt-framework

JWT Framework
MIT License
888 stars 105 forks source link

Avoid PHP warnings about undefined array keys when sanitizing malformed PEMs #556

Closed crocodele closed 6 months ago

crocodele commented 6 months ago

Target branch: ~4.0.x~ 3.4.x

Includes:

When given a malformed PEM string, sanitizePEM() triggers two PHP warnings: Undefined array key 0 and Undefined array key 1.

Spomky commented 6 months ago

Hi,

Many thanks for this PR. The target branch should be 3.4.x. Also, the result of preg_match_all should be verified in a similar way to line 400

crocodele commented 6 months ago

Hi,

Many thanks for this PR. The target branch should be 3.4.x. Also, the result of preg_match_all should be verified in a similar way to line 400

Switched the target branch to 3.4.x and changed to checking the result of preg_match_all() and throwing an exception instead of null coalescing $matches[0][0] and $matches[0][1], in https://github.com/web-token/jwt-framework/pull/556/commits/af17363edb37dda3dfa7ca034a6db21df9f1b722.

Spomky commented 6 months ago

Perfect. Thanks 👍🏼 I added a test to cover this part.