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

Ensure $_SERVER['SCRIPT_NAME'] ends with PHP #2810

Merged
merged 2 commits into from
Apr 7, 2020
Merged

Ensure $_SERVER['SCRIPT_NAME'] ends with PHP #2810

merged 2 commits into from
Apr 7, 2020

Conversation

willnode
Copy link
Contributor

@willnode willnode commented Apr 7, 2020

Description
When doing spark serve, $_SERVER['SCRIPT_NAME'] has a bug that leads to URI like /uploads/avatar/1.jpg being treated as /. This solves the problem by making sure that $_SERVER['SCRIPT_NAME'] is indeed a PHP file, otherwise don't process it futher.
This solves issue #2194

Checklist:

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

@@ -721,7 +721,7 @@ protected function parseRequestURI(): string
$query = $parts['query'] ?? '';
$uri = $parts['path'] ?? '';

if (isset($_SERVER['SCRIPT_NAME'][0]))
if (isset($_SERVER['SCRIPT_NAME'][0]) AND pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_EXTENSION) === 'php')
Copy link
Member

Choose a reason for hiding this comment

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

use && instead of 'AND'

Suggested change
if (isset($_SERVER['SCRIPT_NAME'][0]) AND pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_EXTENSION) === 'php')
if (isset($_SERVER['SCRIPT_NAME'][0]) && pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_EXTENSION) === 'php')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@lonnieezell
Copy link
Member

Good catch. Thanks for this!

@lonnieezell lonnieezell merged commit 7179fcc into codeigniter4:develop Apr 7, 2020
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

3 participants