Skip to content
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

[5.8] Fix appending path to inline Blade views #28141

Merged
merged 2 commits into from
Apr 10, 2019
Merged

[5.8] Fix appending path to inline Blade views #28141

merged 2 commits into from
Apr 10, 2019

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Apr 8, 2019

When appending the view path to Blade views with only one line and opening tags we should take into consideration for closing the PHP tag first before appending the path. I've added tests which should cover quite a few situations.

Thanks to Sisve for making me aware of this: #28117 (comment)

@driesvints
Copy link
Member Author

@bzixilu @sisve Feel free to comment if you see any more discrepancies.

@fitztrev
Copy link
Contributor

fitztrev commented Apr 8, 2019

Short tags (<?=) would be another discrepancy. And, if short_open_tag is enabled, <? also.

@fitztrev
Copy link
Contributor

fitztrev commented Apr 8, 2019

This would be valid PHP code to have in a Blade view too, but would also cause a syntax error with the proposed change:

Hello world
<?php echo 'foo';
/* <?php echo 'bar'; ?> */

@driesvints
Copy link
Member Author

Short tags (<?=) would be another discrepancy. And, if short_open_tag is enabled, <? also.

@fitztrev good call. Added this.

This would be valid PHP code to have in a Blade view too, but would also cause a syntax error with the proposed change:

@fitztrev I get an error when I try to render this in a blade view. I believe closing tags are always needed which makes some of my tests unnecessary actually.

@fitztrev
Copy link
Contributor

fitztrev commented Apr 9, 2019

Here's valid code that does not work under the latest change.

<?php echo '<?xml version="1.0" encoding="UTF-8"?>';

Here's a failing test for it:

'Echo XML declaration' => [
    '<?php echo \'<?xml version="1.0" encoding="UTF-8"?>\';',
    '<?php echo \'<?xml version="1.0" encoding="UTF-8"?>\'; ?><?php /**PATH foo ENDPATH**/ ?>',
],

@driesvints
Copy link
Member Author

@fitztrev Pushed a commit which should take into account all scenarios now. Made use of the tokenizer extension to check for the opening and closing tags. I didn't add a test for the short tags because it will fail if they're not enabled but they should be covered as well now.

driesvints and others added 2 commits April 9, 2019 22:02
When appending the view path to Blade views with only one line and opening tags we should take into consideration for closing the PHP tag first before appending the path. I've addeded tests which should cover quite a few situations.

Thanks to Sisve for making me aware of this: #28117 (comment)
@taylorotwell taylorotwell merged commit 252392d into laravel:5.8 Apr 10, 2019
@driesvints
Copy link
Member Author

@fitztrev thanks for your help with this!

@driesvints driesvints deleted the fix-one-line-includes branch April 11, 2019 06:54
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.

3 participants