-
Notifications
You must be signed in to change notification settings - Fork 913
fix ifinite loop caused by php brace matcher in embedded lexer context #9023
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
base: master
Are you sure you want to change the base?
fix ifinite loop caused by php brace matcher in embedded lexer context #9023
Conversation
…text by comparing token offset position closes apache#7803
| } else if (LexUtilities.textEquals(token.text(), '#', '[')) { // [NETBEANS-4443] PHP 8.0 | ||
| return new int [] {ts.offset(), ts.offset() + token.length()}; | ||
| } else if (LexUtilities.textEquals(token.text(), ':')) { | ||
| //issue 7803 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add a unit test for it, if possible, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ... I will see, this would imply a mock mime type for which the coloring lexer will use an embedded php token id.
tmysik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, thank you.
|
@haidubogdan It would be helpful to see an example that causes a loop. While I agree, that a test would be the best case, I think a review can substitute that. Infinite loops are really ugly to test for (at least the failing variant). |
|
@matthiasblaesing |
|
@haidubogdan I'd like to "see" the problem, so instructions how to reproduce (if necessary with code) would be great. |
|
I've created this branch master...haidubogdan:netbeans:t_php_bracematcher_infinite_loop_test It's just for simulating the infinite loop. Context: I have a custom language support (text/x-php-test). |
This pull request tries to fix issue #7803 .
Php brace matcher used for highlighting (if, foreach ) statements like
<?php if ($x): ?> ...<?php endif;?>loops through tokens until it finds the opening parenthesis.The current implementation can trigger a infinite loop for a embedded usage of Php lexer as there is no exit mechanism beside the PhpTokenId.TOKEN check.
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)