Skip to content

Fix PHP 8.5 recursive tokenization during token_get_all #19547

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

Closed
wants to merge 6 commits into from

Conversation

kubawerlos
Copy link
Contributor

@kubawerlos kubawerlos commented Aug 21, 2025

Fixes #19507

Changes for the fix are authored by @arnaud-lb in #19507 (comment).

@arnaud-lb, if you were planning to raise the PR by yourself, feel free to close this PR and do it.

@kubawerlos kubawerlos marked this pull request as ready for review August 21, 2025 20:48
@TimWolla TimWolla requested a review from arnaud-lb August 21, 2025 21:13
@@ -766,6 +769,8 @@ ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename)
zend_set_compiled_filename(filename);
CG(zend_lineno) = 1;
CG(increment_lineno) = 0;
SCNG(on_event) = NULL;
SCNG(on_event_context) = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Please also reset SCNG(on_event_context) here:

LANG_SCNG(on_event) = NULL;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (I hope).

@arnaud-lb
Copy link
Member

Please also add a test where the error handler throws an exception

@arnaud-lb arnaud-lb closed this in 94d0b41 Aug 22, 2025
@arnaud-lb
Copy link
Member

Thank you @kubawerlos!

@@ -1636,6 +1641,9 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("integer"){TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_error(E_DEPRECATED, "Non-canonical cast (integer) is deprecated, use the (int) cast instead");
if (PARSER_MODE() && EG(exception)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

PARSER_MODE() condition not required, checked already above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kubawerlos kubawerlos deleted the fix_19507 branch August 22, 2025 17:40
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.

PHP 8.5: Recursive tokenization during token_get_all result on error
4 participants