-
Notifications
You must be signed in to change notification settings - Fork 913
Description
Apache NetBeans version
Apache NetBeans 23
What happened
I've worked on a plugin for blade templates which required Php Embeddings.
During the development I always had an issue that the plugin freeze when the file contained an php embedded text with ":" character.
Ex:
@test($x ?: $y)
Any action like delete, typing on this snippet would trigger a complete freeze for Netbeans.
Language / Project Type / NetBeans Component
PHP
How to reproduce
Have a custom language which will contain Php Embedding language like PHPTokenId.languageInPHP().
Have a text wrapped in parenthesis or brackets which will contain a colon character ":".
@test($x ?: $y)
Any action like delete, typing on this snippet would trigger a freeze.
In order to help with the fix / debugging I've created a forked netbeans branch from my blade plugin on https://github.com/haidubogdan/netbeans/tree/php_blade_for_brace_matcher_issue
Did this work correctly in an earlier version?
Apache NetBeans 18
Operating System
Windows OS
JDK
17
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
After some investigation I found the issue to be on PhpBracesMatcher.
On line 113 there is a condition that when the text contains a ":" character a while loop will be executed as long it detects a PHP_TOKEN lexer token. Parenthesis or brackets are matched as PHP_TOKEN PhpTokenId.
In a full embedded context this would be fine as the first token for a php lexer is always "<?" but in a Php inLanguage embedded context like we can have for blade templates the text with ":" character wrapped in parenthesis will trigger an infinite loop when Php Braces matching is called.
Are you willing to submit a pull request?
Yes
