Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:5.8from
driesvints:fix-one-line-includes
Apr 10, 2019
Merged

taylorotwell merged 2 commits into
laravel:5.8from
driesvints:fix-one-line-includes

Conversation

@driesvints

@driesvints driesvints commented Apr 8, 2019 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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

@fitztrev

fitztrev commented Apr 8, 2019

Copy link
Copy Markdown
Contributor

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

@fitztrev

fitztrev commented Apr 8, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

fitztrev commented Apr 9, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread src/Illuminate/View/Compilers/BladeCompiler.php Outdated
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
Copy Markdown
Member Author

@fitztrev thanks for your help with this!

@driesvints
driesvints deleted the fix-one-line-includes branch April 11, 2019 06:54
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
[5.8] Fix appending path to inline Blade views
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