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

fastcgi: Make sure splitPos handles empty SplitPath correctly #3491

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

wylfen
Copy link
Contributor

@wylfen wylfen commented Jun 12, 2020

In commit f2ce81c, support for multiple path splitters was added. The
type of SplitPath changed from string to []string, and splitPos was
changed to loop through all values in SplitPath.

Before that commit, if SplitPath was empty, strings.Index returned 0 and
PATH_INFO was set correctly in buildEnv.

Currently, however, splitPos returns -1 for empty values of SplitPath,
behaving as if a split position could not be found at all. PATH_INFO is
then never set in buildEnv and remains empty.

Restore the old behaviour by explicitly checking whether SplitPath is
empty and returning 0 in splitPos.

Closes #3490

@CLAassistant
Copy link

CLAassistant commented Jun 12, 2020

CLA assistant check
All committers have signed the CLA.

In commit f2ce81c, support for multiple path splitters was added. The
type of SplitPath changed from string to []string, and splitPos was
changed to loop through all values in SplitPath.

Before that commit, if SplitPath was empty, strings.Index returned 0 and
PATH_INFO was set correctly in buildEnv.

Currently, however, splitPos returns -1 for empty values of SplitPath,
behaving as if a split position could not be found at all. PATH_INFO is
then never set in buildEnv and remains empty.

Restore the old behaviour by explicitly checking whether SplitPath is
empty and returning 0 in splitPos.

Closes caddyserver#3490
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Excellent, thank you -- I'll let @francislavoie give it a once-over as well.

@mholt mholt added this to the v2.1.0 milestone Jun 12, 2020
@mholt mholt requested a review from francislavoie June 12, 2020 15:57
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for catching that. My change was definitely with PHP in mind, I didn't consider split not being used. Thanks for the detailed report, it's very much appreciated ❤️

@mholt mholt merged commit fa4cdde into caddyserver:master Jun 12, 2020
@mholt
Copy link
Member

mholt commented Jun 12, 2020

Yes, we wish for more bug reports and contributions following this pattern. 🙂 Thank you!

@wylfen wylfen deleted the 3490-splitPos branch June 12, 2020 19:03
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.

PATH_INFO is not set correctly when SplitPath is empty
4 participants