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

Replace URI string casts #4716

Merged
merged 2 commits into from May 25, 2021
Merged

Replace URI string casts #4716

merged 2 commits into from May 25, 2021

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented May 21, 2021

Description
Due to the following:

// Check if this is an internal URI
$config = config('App');
$baseUri = new self($config->baseURL);
// If the hosts matches then assume this should be relative to baseURL
if ($this->getHost() === $baseUri->getHost())
{
// Check for additional segments
$basePath = trim($baseUri->getPath(), '/') . '/';
$trimPath = ltrim($path, '/');
if ($basePath !== '/' && strpos($trimPath, $basePath) !== 0)
{
$path = $basePath . $trimPath;
}
// Check for forced HTTPS
if ($config->forceGlobalSecureRequests)
{
$scheme = 'https';
}
}

... URI::__toString() is only suitable for project URLs, because any partial match of baseURL will be a false positive. Following on #4715, this PR removes the remaining string casts of URI when they are not explicitly a project URI.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • n/a User guide updated
  • Conforms to style guide

@MGatner MGatner requested a review from samsonasik May 25, 2021 15:24
@MGatner MGatner merged commit 59e34a1 into codeigniter4:develop May 25, 2021
@MGatner MGatner deleted the uri-string branch May 25, 2021 15:46
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.

None yet

2 participants