-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Freezing issue with coffeescript regex under some circumstances #66
Comments
I appreciate the heads up! If this causes to highlight.php to freeze/crash too then it's important for us to fix it as well 👍 |
If you wanted to test that'd be great... I'd think you'd be affected also unless the PHP regex engine is much smarter or could self-terminate or something. |
It looks like highlight.php on PHP 7.1 does not crash/hang with the given test file in that issue. However, it also does not match the expected output in your PR. Still a bug nonetheless but doesn't seem to affect us quite as bad (at least not in my very minimal testing). |
Oh? I'd be curious what your output is... and very interesting it doesn't freeze... |
Example PHP code: <?php
use Highlight\Highlighter;
require './vendor/autoload.php';
$s = <<<HLJS
TEST@TEST(1):online> TEST TEST
version=3 meow=BLAH+BLAH\\/BLAH+BLAH= data=BLAH+BLAH\\/BLAH\\/BLAH+BLAH\\/BLAH\\/BLAH+BLAH\\/BLAH+BLAH+BLAH+BLAH+BLAH\\/BLAH+BLAH+BLAH+BLAH+BLAH+BLAH+BLAH+BLAH\\/BLAH\\/BLAH\\/BLAH+BLAH+BLAH\\/BLAH\\/QfwwjxZ+i3\\/I0\\/Ku4TtlywzkUCgjcKM8WDHbOlj0dMu8xQTEoucssL+cNi5migI6wdlvEzKlGsBcwT3QXAz4qdZ5n\\/aJOxBSJ5XnIGfgeZr\\/AJKEm7q\\/wfU5hWp3bkXNaba1PMln76N2BWP9vb2OJYNT2wMsxhm\\/RAr22gj\\/crvDlg95T+MxcIsjz0mt2wXUr\\/coqiNWmJ2jpmLwhF0HuLk9oHsc0tLh0JuaqGETFegnBAXdV3nrlOVZTSf3dz7Eotshzn8JbOXSKk12CITzFONf3BxDPyvBiEPIjFaIHGXsPKMGR6XqF4A3SGsbpzVsLRGy5Lb2OkumuBQMNArAZPhPkkAGBH9ZOkmBPJpFcBo4tRhuwgY9saa0VqInvjXE1H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iF\\/rtwtUJF01zgNVRzU3dFTTR7MFa\\/ios6zihg2Xjt0ev1riyiNGOro1Kl3I1+CiLiLBSJhE2gS6wX8f86VLzAw\\/XTV+1Z3Qan6Mwdhp+ZVBBkcIVrQU\\/U6fNmIWitevGROkHHKY8MhrUG1AqLwsZir7acWb0HbjMSiVpROUUw9754BtB53GH17X739xbKGzyMvh6cJIrWPvvMQKNyL2RVHm5XhwPIBgTSX059NQ9PQD+Ps91NIR0V+Bbs=
HLJS;
$hl = new Highlighter();
$r = $hl->highlight('coffeescript', $s);
print $r->value; Output: TEST@TEST(<span class="hljs-number">1</span>):online> TEST TEST
version=<span class="hljs-number">3</span> meow=BLAH+BLAH\/BLAH+BLAH= data=BLAH+BLAH\/BLAH\/BLAH+BLAH\/BLAH\/BLAH+BLAH\/BLAH+BLAH+BLAH+BLAH+BLAH\/BLAH+BLAH+BLAH+BLAH+BLAH+BLAH+BLAH+BLAH\/BLAH\/BLAH\/BLAH+BLAH+BLAH\/BLAH\/QfwwjxZ+i3\/I0\/Ku4TtlywzkUCgjcKM8WDHbOlj0dMu8xQTEoucssL+cNi5migI6wdlvEzKlGsBcwT3QXAz4qdZ5n\/aJOxBSJ5XnIGfgeZr\/AJKEm7q\/wfU5hWp3bkXNaba1PMln76N2BWP9vb2OJYNT2wMsxhm\/RAr22gj\/crvDlg95T+MxcIsjz0mt2wXUr\/coqiNWmJ2jpmLwhF0HuLk9oHsc0tLh0JuaqGETFegnBAXdV3nrlOVZTSf3dz7Eotshzn8JbOXSKk12CITzFONf3BxDPyvBiEPIjFaIHGXsPKMGR6XqF4A3SGsbpzVsLRGy5Lb2OkumuBQMNArAZPhPkkAGBH9ZOkmBPJpFcBo4tRhuwgY9saa0VqInvjXE1Hyhffx8U5xwu28hztiebpuA3EyeJV+CPfpfEP3I1sQrtblSo9\/cZybBcVpaTO+Gbflksf1MW5RindyQwAJcygINFnAXwcOPfh8Y8ea8JzlVGrg2a6fPRTwESdM7E4mC56JaftlY8G5ia3v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JIrWPvvMQKNyL2RVHm5XhwPIBgTSX059NQ9PQD+Ps91NIR0V+Bbs= |
I wonder if that's not actually a problem with your port itself in how it deals with boundaries in it's parsing engine? Boundaries aren't necessarily required and shouldn't be assumed unless a grammar says so. Do you run all our markup and detection tests? |
That might be the case? PHP 7.1 uses PCRE 8.x and PHP 7.3 uses PCRE 10.x. I don't have 7.3 installed on my current machine so I can't confirm behavior with PCRE 10.x |
Does \b do something different in PHP? In that output both (of course this sample is ridiculous) :-) |
Not that I'm aware of, highlight.php/Highlight/RegExUtils.php Lines 46 to 60 in a26ab4e
|
Do you run all our markup and detection tests?
Well, it must be different, OR else there is a bug in your engine somewhere. :-) |
Minus a few tests that we skip due to unknown failures (i.e. haven't been able to figure them out), they all pass. |
You could fix the "tie" issues if you wanted. Alphabetical order breaks ties, LOL. So the first alphabetically always wins. |
Did you port over all our recent (last year) improvements to look-ahead matching? If not that could probably explain the differences, but also means your parser is broken for many cases revolving around look-ahead and proper boundary matching. Big ones:
The old parser would break up the text and run regexes against small pieces, but you can't do that if you want all the features of regex to work properly... you have to always run the regexes (indexed properly) against the full string. |
...wait, is that how highlight.js does it? 😂
Off the top of your head, do you know any languages using lookaheads? I did port over all your changes but I can't say I've tested it further than just making sure our unit tests match yours. e.g. https://github.com/scrivo/highlight.php/blob/master/Highlight/Language.php#L293-L294 |
Yes. Not my choice. It's just a loop, and in order to "win" you have to have a higher score than a prior match... so in cases of ties the first item always wins since equal is not greater than. Related: highlightjs/highlight.js#2275
Several now use look-aheads. I believe that PR includes some of those grammar changes. Actually that wouldn't be the problem with I just checked and |
How does your HTTP markup test fail exactly? |
That's good to know. I'll implement that functionality on here to match that behavior and get tied unit tests passing.
Then based on our unit tests passing and match yours, we're handling lookaheads correctly, right?
Failing HTTP test
Failing Haskell Test
|
Most likely. Our test suite isn't anywhere close to 100% coverage of all rules though.
Looks like your sublanguage support is maybe broken somehow? Perhaps you don't support auto-detect of sublanguages? HTTP is a pretty simple syntax.
Likely a bug in your recursive rule support using "self"? hljs.COMMENT(
'{-',
'-}',
{
contains: ['self']
}
) |
Know anything about Zephir? |
Thanks for the hints on the failing HTML/Haskell tests. I'm going to investigate them this weekend and see if I can fix them.
In what context? I familiar with that it exists and I've looked at it before but never worked with it. Or is it an allowed failed test somewhere for highlight.php? |
highlightjs/highlight.js#2375
You may want to follow this, not sure how important you consider this type of issue. I think it's pretty bad and plan to release 9.18.1 as soon as we have an approved fix.
The text was updated successfully, but these errors were encountered: