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

Normalize dir separator of Exceptions::cleanPath and added more paths to clean #2847

Merged
merged 5 commits into from
Apr 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Normalize dir separator of Exceptions::cleanPath
paulbalandan committed Apr 19, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit aa1b3cfb523d27371ebc653a0a1d8016f2eee2e2
26 changes: 16 additions & 10 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
@@ -372,17 +372,23 @@ protected function determineCodes(Throwable $exception): array
*/
public static function cleanPath(string $file): string
{
if (strpos($file, APPPATH) === 0)
switch (true)
{
$file = 'APPPATH/' . substr($file, strlen(APPPATH));
}
elseif (strpos($file, SYSTEMPATH) === 0)
{
$file = 'SYSTEMPATH/' . substr($file, strlen(SYSTEMPATH));
}
elseif (strpos($file, FCPATH) === 0)
{
$file = 'FCPATH/' . substr($file, strlen(FCPATH));
case strpos($file, VIEWPATH) === 0:
$file = 'VIEWPATH' . DIRECTORY_SEPARATOR . substr($file, strlen(VIEWPATH));
paulbalandan marked this conversation as resolved.
Show resolved Hide resolved
break;
case strpos($file, APPPATH) === 0:
$file = 'APPPATH' . DIRECTORY_SEPARATOR . substr($file, strlen(APPPATH));
break;
case strpos($file, SYSTEMPATH) === 0:
$file = 'SYSTEMPATH' . DIRECTORY_SEPARATOR . substr($file, strlen(SYSTEMPATH));
break;
case strpos($file, FCPATH) === 0:
$file = 'FCPATH' . DIRECTORY_SEPARATOR . substr($file, strlen(FCPATH));
break;
case defined('VENDORPATH') && strpos($file, VENDORPATH) === 0;
$file = 'VENDORPATH' . DIRECTORY_SEPARATOR . substr($file, strlen(VENDORPATH));
break;
}

return $file;
18 changes: 18 additions & 0 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
@@ -87,6 +87,14 @@
define('TESTPATH', realpath($paths->testsDirectory) . DIRECTORY_SEPARATOR);
}

/**
* The path to the views directory
*/
if (! defined('VIEWPATH'))
paulbalandan marked this conversation as resolved.
Show resolved Hide resolved
{
define('VIEWPATH', realpath($paths->viewDirectory) . DIRECTORY_SEPARATOR);
}

/*
* ---------------------------------------------------------------
* GRAB OUR CONSTANTS & COMMON
@@ -139,6 +147,16 @@ class_alias('Config\Services', 'CodeIgniter\Services');
// Now load Composer's if it's available
if (is_file(COMPOSER_PATH))
{
/**
* The path to the vendor directory.
*
* We do not want to enforce this, so set the constant if Composer was used.
*/
if (! defined('VENDORPATH'))
{
define('VENDORPATH', realpath(ROOTPATH . 'vendor') . DIRECTORY_SEPARATOR);
}

require_once COMPOSER_PATH;
}