Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent type conversions issues when parsing time-fractions #710

Merged
merged 1 commit into from Mar 23, 2021

Conversation

lcobucci
Copy link
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
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
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
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
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