Skip to content

Prevent type conversions issues when parsing time-fractions#710

Merged
lcobucci merged 1 commit into4.0.xfrom
guard-against-potential-precision-issues
Mar 23, 2021
Merged

Prevent type conversions issues when parsing time-fractions#710
lcobucci merged 1 commit into4.0.xfrom
guard-against-potential-precision-issues

Conversation

@lcobucci
Copy link
Copy Markdown
Owner

We received reports of users experiencing exceptions when parsing JWTs with timestamps with precision beyond microseconds on time-fractions.

This guards against having any kind of edge-case when dealing with floats as input to the creation of DateTimeImmutable objects.

We received reports of users experiencing exceptions when parsing JWTs
with timestamps with precision beyond microseconds on time-fractions.

This guards against having any kind of edge-case when dealing with
floats as input to the creation of DateTimeImmutable objects.
Copy link
Copy Markdown
Contributor

@yassinrais yassinrais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/Token/Parser.php:118

     * @param int|float|string $timestamp

Are you sur that its okey to put even string into param type ?

@param => accepted type in 'documentation'

@lcobucci
Copy link
Copy Markdown
Owner Author

lcobucci commented Mar 23, 2021

src/Token/Parser.php:118

     * @param int|float|string $timestamp

Are you sur that its okey to put even string into param type ?

@param => accepted type in 'documentation'

Not accepting it is a BC-break with previously created tokens in v4. So, we have to support until v5 - that's also why I added a test to cover that.

We can mark that as deprecated but it's not really a hill I'd die on.

Copy link
Copy Markdown
Contributor

@yassinrais yassinrais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some bad news : https://3v4l.org/pTqmM 🤔 wait a minute nvm, i forgot the was u.u 😅 and number_format add .u format to integer

@yassinrais
Copy link
Copy Markdown
Contributor

I dont have anything to add 💪 gj

@lcobucci lcobucci merged commit ae4165a into 4.0.x Mar 23, 2021
@lcobucci lcobucci deleted the guard-against-potential-precision-issues branch March 23, 2021 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of json_encode() to convert time fractions to microseconds cause precision issues

2 participants