Skip to content

Conversation

@samsonasik
Copy link
Member

Given the following code:

function run()
{
    $eval_links = '$link = clean_link("$1","$2")';

    echo preg_replace('{\[link:([^\|].*?)\|([^\]].*?)\]}ei',"$eval_links",$str);
}

it cause crash:

There was 1 error:

1) Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\PregReplaceEModifierRectorTest::test with data set #2 ('/Users/samsonasik/www/rector-...hp.inc')
PhpParser\Error: Syntax error, unexpected '}' on line 1

/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:318
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:159
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php:51
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php:32
/Users/samsonasik/www/rector-src/src/PhpParser/Parser/SimplePhpParser.php:38
/Users/samsonasik/www/rector-src/rules/Php72/NodeFactory/AnonymousFunctionFactory.php:157
/Users/samsonasik/www/rector-src/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php:105

Ref https://getrector.org/demo/d1c86304-9f2a-4614-b636-f9bb1ebdaa16

This PR try to resolve it

Fixes rectorphp/rector#7635

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @themrwilliams

@samsonasik
Copy link
Member Author

It seems not really working, ref https://3v4l.org/P4mPQ#v5.2.17 vs https://3v4l.org/22DeW#v5.2.17, probably skip is the way to go.

@samsonasik
Copy link
Member Author

I skipped 8b0e53f

@samsonasik samsonasik changed the title [Php55] Handle curly parentheses delimiter on PregReplaceEModifierRector [Php55] Handle crash on curly parentheses delimiter on PregReplaceEModifierRector Dec 3, 2022
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik
Copy link
Member Author

Ok, I got the solution by verify Encapsed parts value which start with { and end with } b5756bf

@samsonasik samsonasik marked this pull request as draft December 3, 2022 03:00
@samsonasik
Copy link
Member Author

@samsonasik samsonasik marked this pull request as ready for review December 3, 2022 03:30
@samsonasik
Copy link
Member Author

Finally, All checks have passed 🎉 @TomasVotruba I think it is ready.

@samsonasik
Copy link
Member Author

I added failing fixture e inside regex not as modifier 27a6d4c

@samsonasik
Copy link
Member Author

Fixed 🎉 d150be8

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba
Copy link
Member

Thank you 🙏

@TomasVotruba TomasVotruba merged commit 1664739 into main Dec 3, 2022
@TomasVotruba TomasVotruba deleted the handle-crash-curly-parentheses-delimiter branch December 3, 2022 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System error: "Syntax error, unexpected ':', expecting ',' or ']' or ')':1"

4 participants