Skip to content

Commit 8113f10

Browse files
bug #40242 [ErrorHandler] Fix error caused by include + open_basedir (stlrnz)
This PR was submitted for the 5.x branch but it was merged into the 5.2 branch instead. Discussion ---------- [ErrorHandler] Fix error caused by `include` + open_basedir | 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). Commits ------- 9ad7832 [ErrorHandler] Fix error caused by `include` + open_basedir
2 parents faf7269 + 9ad7832 commit 8113f10

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private function include(string $name, array $context = []): string
352352
extract($context, \EXTR_SKIP);
353353
ob_start();
354354

355-
include file_exists($name) ? $name : __DIR__.'/../Resources/'.$name;
355+
include is_file(\dirname(__DIR__).'/Resources/'.$name) ? \dirname(__DIR__).'/Resources/'.$name : $name;
356356

357357
return trim(ob_get_clean());
358358
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy