Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[JsonPath] Handle slice selector overflow #60798

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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
from

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Jun 16, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Slice selector integers must always be in the interval [-(2^53) + 1, (2^53) - 1], and leading 0 are forbidden.

@carsonbot carsonbot added this to the 7.3 milestone Jun 16, 2025
@alexandre-daubois alexandre-daubois force-pushed the int-overflow-handle branch 2 times, most recently from 82834d9 to b9231c9 Compare June 16, 2025 09:26
$start = '' !== $matches[1] ? (int) $matches[1] : null;
$end = '' !== $matches[2] ? (int) $matches[2] : null;
$step = isset($matches[3]) && '' !== $matches[3] ? (int) $matches[3] : 1;
$start = '' !== $startStr ? (int) $startStr : null;
Copy link
Member

Choose a reason for hiding this comment

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

How does this work if $startStr is the representation of an integer that exceeds PHP_INT_MAX? Or is lower than PHP_INT_MINX?

Copy link
Member Author

@alexandre-daubois alexandre-daubois Jun 16, 2025

Choose a reason for hiding this comment

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

It will be caught by the call to JsonPathUtils::isIntegerOverflow() above: safe JSON integer interval is narrower compared to PHP integer interval. It may be different on 32 bits systems though. I don't know how common it is these days to add a check for it? It would imply more complexity as we would compare numbers as strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants