-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix lexing of nested heredoc strings in token_get_all() #31
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
Merged
php-pulls
merged 1 commit into
php:master
from
nikic:fixNestedHeredocLexingForTokenizerExt
Aug 20, 2012
Merged
Fix lexing of nested heredoc strings in token_get_all() #31
php-pulls
merged 1 commit into
php:master
from
nikic:fixNestedHeredocLexingForTokenizerExt
Aug 20, 2012
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes bug #60097. Before two global variables CG(heredoc) and CG(heredoc_len) were used to track the current heredoc label. In order to support nested heredoc strings the *previous* heredoc label was assigned as the token value of T_START_HEREDOC and the language_parser.y assigned that to CG(heredoc). This created a dependency of the lexer on the parser. Thus the token_get_all() function, which accesses the lexer directly without also running the parser, was not able to tokenize nested heredoc strings (and leaked memory). Same applies for the source-code highlighting functions. The new approach is to maintain a heredoc_label_stack in the lexer, which contains all active heredoc labels. As it is no longer required, T_START_HEREDOC and T_END_HEREDOC now don't carry a token value anymore. In order to make the work with zend_ptr_stack in this context more convenient I added a new function zend_ptr_stack_top(), which retrieves the top element of the stack (similar to zend_stack_top()).
+1 |
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 9, 2015
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 12, 2015
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 15, 2015
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 17, 2015
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 17, 2015
hikari-no-yume
added a commit
to hikari-no-yume/php-src
that referenced
this pull request
Jan 17, 2015
Further error checks
EdmondDantes
added a commit
to true-async/php-src
that referenced
this pull request
Jul 14, 2025
EdmondDantes
added a commit
to true-async/php-src
that referenced
this pull request
Jul 14, 2025
…y have different keys.
EdmondDantes
added a commit
to true-async/php-src
that referenced
this pull request
Jul 14, 2025
…mpatible syntax - Change `data[]` to `data[1]` in zend_async_waker_trigger_s structure - Adjust memory allocation calculations to account for included array element - Ensures compatibility with MSVC compiler while maintaining functionality
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes bug #60097 (https://bugs.php.net/bug.php?id=60097).
Before, two global variables CG(heredoc) and CG(heredoc_len) were used to
track the current heredoc label. In order to support nested heredoc
strings the previous heredoc label was assigned as the token value of
T_START_HEREDOC and the language_parser.y assigned that to CG(heredoc).
This created a dependency of the lexer on the parser. Thus the
token_get_all() function, which accesses the lexer directly without
also running the parser, was not able to tokenize nested heredoc strings
(and leaked memory). Same applies for the source-code highlighting
functions.
The new approach is to maintain a heredoc_label_stack in the lexer, which
contains all active heredoc labels.
As it is no longer required, T_START_HEREDOC and T_END_HEREDOC now don't
carry a token value anymore.
In order to make the work with zend_ptr_stack in this context more
convenient I added a new function zend_ptr_stack_top(), which retrieves the
top element of the stack (similar to zend_stack_top()).