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

[ErrorHandler] Fix error caused by include + open_basedir #40242

Merged
merged 1 commit into from Mar 16, 2021

Conversation

stlrnz
Copy link
Contributor

@stlrnz stlrnz commented Feb 18, 2021

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

#37492 introduced the option to specify your own error template using HtmlErrorRenderer::setTemplate('...');

However, the implementation using file_exists(...) in include can cause an error when not setting a custom template.

php.WARNING: Warning: file_exists(): open_basedir restriction in effect. File(assets/css/error.css) is not within the allowed path(s): (...) {"exception":"[object] (ErrorException(code: 0): Warning: file_exists(): open_basedir restriction in effect. File(assets/css/error.css) is not within the allowed path(s): (...) at ...\vendor\symfony\error-handler\ErrorRenderer\HtmlErrorRenderer.php:355)"} []

As you can see the error is caused by checking file_exists(...) using relative paths in environments with a restrictive open_basedir policy.

The proposed solution always uses absolute paths to include errors templates (and other files).

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title [ErrorHandler] Fix error caused by include Fix error caused by include Feb 18, 2021
@stlrnz stlrnz changed the title Fix error caused by include [ErrorHandler] Fix error caused by include Feb 18, 2021
@stlrnz stlrnz changed the title [ErrorHandler] Fix error caused by include Fix error caused by include Feb 18, 2021
@nicolas-grekas nicolas-grekas changed the title Fix error caused by include [ErrorHandler] Fix error caused by include Feb 18, 2021
@carsonbot
Copy link

Hey!

I see that more good work is coming your way.

I think @awoimbee has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@nicolas-grekas nicolas-grekas added this to the 5.2 milestone Feb 22, 2021
@nicolas-grekas nicolas-grekas changed the title [ErrorHandler] Fix error caused by include [ErrorHandler] Fix error caused by include + open_basedir Mar 16, 2021
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I updated the implementation)

@nicolas-grekas
Copy link
Member

Thank you @stlrnz.

@nicolas-grekas nicolas-grekas merged commit 8113f10 into symfony:5.2 Mar 16, 2021
@fabpot fabpot mentioned this pull request Mar 29, 2021
@PhilETaylor
Copy link
Contributor

Only just seen this. Sorry that my implementation of #37492 caused issued, and thank you for fixing it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants