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

Conversation

Projects
None yet
3 participants
@driesvints
Copy link
Member

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 driesvints force-pushed the driesvints:fix-one-line-includes branch from 32fb6d1 to aa10a6a Apr 8, 2019

@driesvints

This comment has been minimized.

Copy link
Member Author

driesvints commented Apr 8, 2019

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

@fitztrev

This comment has been minimized.

Copy link
Contributor

fitztrev commented Apr 8, 2019

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

@fitztrev

This comment has been minimized.

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 driesvints force-pushed the driesvints:fix-one-line-includes branch from aa10a6a to 04fcebd Apr 9, 2019

@driesvints

This comment has been minimized.

Copy link
Member Author

driesvints commented Apr 9, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member Author

driesvints commented Apr 9, 2019

@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 driesvints force-pushed the driesvints:fix-one-line-includes branch from f5374a2 to 656259e Apr 9, 2019

Fix appending path to inline Blade views
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)

@driesvints driesvints force-pushed the driesvints:fix-one-line-includes branch from 656259e to 6be12dd Apr 9, 2019

@taylorotwell taylorotwell merged commit 252392d into laravel:5.8 Apr 10, 2019

1 check passed

continuous-integration/styleci/pr The analysis has passed
Details
@driesvints

This comment has been minimized.

Copy link
Member Author

driesvints commented Apr 11, 2019

@fitztrev thanks for your help with this!

@driesvints driesvints deleted the driesvints:fix-one-line-includes branch Apr 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.