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

500 errors produced by SiteTree with url segment "0" #2680

Closed
shanholmes opened this issue Aug 15, 2021 · 5 comments
Closed

500 errors produced by SiteTree with url segment "0" #2680

shanholmes opened this issue Aug 15, 2021 · 5 comments

Comments

@shanholmes
Copy link

shanholmes commented Aug 15, 2021

To reproduce:
Hit your Silverstripe site with the route /0/anything. The anything in the URL can be literally any value but the URL must contain 0 as the first parameter.

https://www.loom.com/share/31c8626c785a432abd0adb4d0d312d68

Expected behaviour:
If the URL does not exist within the CMS or is not valid, the site should return a 404 error.

Current behaviour:
The site returns a 500 error.

Environment:
Tested with Silverstripe 4.8 (PHP 7.4), Silverstripe 3.7.3 (PHP 7.3).

PRs

adrhumphreys added a commit to adrhumphreys/silverstripe-cms that referenced this issue Aug 15, 2021
@maxime-rainville
Copy link
Contributor

The problem is that on this line, we assigned the URL segment to a variable and we check that if it's falsy. We need to do a strict check instead for null.

if (!$URLSegment = $request->param('URLSegment')) {

There's a potential follow up problem that the CMS won't let you assign 0 as a URL segment to a page. It's happy with 1

@Zazama
Copy link

Zazama commented Jan 20, 2023

We've been getting many bot requests lately that call '/0/...' URLs and cause 500 errors. I've seen that there was a PR (#2681) but it has not been merged.

Is there something that was missing in the PR or would you accept a new one that checks if the value is null instead of falsy?
It would be cool to get rid of those errors without resorting to the webserver config.

@shanholmes
Copy link
Author

Yeah we have had a bit of a flood recently as well. Let me know if there is anything I can do to help.

@shanholmes
Copy link
Author

This is still an issue and has since been carried over to the 5 branch of the cms.

@GuySartorelli GuySartorelli changed the title 500 errors produced by specific url format 500 errors produced by SiteTree with url segment "0" Nov 19, 2023
@emteknetnz emteknetnz self-assigned this Nov 19, 2023
@emteknetnz
Copy link
Member

Linked PR has been merged, this will auto-tag on the 4.13 shortly and will auto-tag on the 5.1 branch within the next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants