Fix bug in PHP syntax highlighting#203
Conversation
|
Wouter, thanks for fixing this. FYI, below I reproduce the analysis made by Claude Code: Root Cause: Catastrophic Backtracking The bug is caused by catastrophic backtracking in PCRE, triggered by the interaction between the The regex in question Inside the meta mode (PHP attributes
These are combined into a single mega-regex alternation by the highlight engine. Why case_insensitive: true is the catalyst The Without With The chain of failure
Why shorter names work
The threshold is around 28 characters. Why removing Without the lookahead, variant 1's greedy match succeeds immediately — there's nothing to fail and trigger backtracking. The contains sub-rule ( |
|
Damn 😅 Thanks for the explanation! |
|
Oh that makes sense, then we would need another fix and can probably simplify the variants into 1. |
53d984c to
ebaae6a
Compare
|
Now with a nicer fix :) |
javiereguiluz
left a comment
There was a problem hiding this comment.
Great! Thanks a lot Wouter.
|
It's merged now! Thanks. |
Don't ask me why and how. I don't see why it breaks in this UX example, but doesn't in e.g. https://symfony.com/doc/current/messenger.html#creating-a-message-handler And I also don't see how this change fixes it. But it fixes it, and it doesn't appear to break any other PHP attributes in the test suite of this library (which is quite extensive).