No error returned when Max-Days is invalid #149

Closed
opened 2026-01-19 18:29:11 +00:00 by michael · 7 comments
Owner

Originally created by @anihm136 on GitHub.

When a file is uploaded with a very high value set for Max-Days header, the server returns a URL. However, the URL leads to a 404 page

Expected behavior:
The server should return an appropriate 400 response when an invalid value is set for the header

Originally created by @anihm136 on GitHub. When a file is uploaded with a very high value set for `Max-Days` header, the server returns a URL. However, the URL leads to a 404 page **Expected behavior**: The server should return an appropriate 400 response when an invalid value is set for the header
michael added the hacktoberfest label 2026-01-19 18:29:11 +00:00
Author
Owner

@anihm136 commented on GitHub:

Maybe overkill, but I did a binary search and it appears to fail at 8217934 days

@anihm136 commented on GitHub: Maybe overkill, but I did a binary search and it appears to fail at 8217934 days
Author
Owner

@paolafrancesca commented on GitHub:

Indeed it seems so @jimmybrancaccio, glad you spotted this so soon.
I've reverted the PR

@kugiyasan it should be something like this, can you create a new PR?

} else if (!metadata.MaxDate.IsZero() && time.Now().After(metadata.MaxDate)) {

thanks

@paolafrancesca commented on GitHub: Indeed it seems so @jimmybrancaccio, glad you spotted this so soon. I've reverted the PR @kugiyasan it should be something like this, can you create a new PR? ``` } else if (!metadata.MaxDate.IsZero() && time.Now().After(metadata.MaxDate)) { ``` thanks
Author
Owner

@jimmybrancaccio commented on GitHub:

I'm curious if this broke uploading as I am getting a 400 error now on my self-hosted install and when attempting to upload a file via the command line. On the command line I see:

curl --upload-file ./hello.txt http://172.18.0.77:8080/hello.txt
Invalid MaxDate, make sure Max-Days is smaller than 290 years

I didn't provide the header and I assume it shouldn't be a requirement?

Edit:

I wonder if in server/handlers.go it should be something like:

} else if (metadata.MaxDate) && (time.Now().After(metadata.MaxDate)) {

I don't know anything about Go, but I think you may understand my point? Basically it checks to see if metadata.MaxDate has a value and performs the time.Now().After(metadata.MaxDate) condition check.

@jimmybrancaccio commented on GitHub: I'm curious if this broke uploading as I am getting a 400 error now on my self-hosted install and when attempting to upload a file via the command line. On the command line I see: ``` curl --upload-file ./hello.txt http://172.18.0.77:8080/hello.txt Invalid MaxDate, make sure Max-Days is smaller than 290 years ``` I didn't provide the header and I assume it shouldn't be a requirement? **Edit:** I wonder if in `server/handlers.go` it should be something like: ```go } else if (metadata.MaxDate) && (time.Now().After(metadata.MaxDate)) { ``` I don't know anything about Go, but I think you may understand my point? Basically it checks to see if `metadata.MaxDate` has a value and performs the `time.Now().After(metadata.MaxDate)` condition check.
Author
Owner

@paolafrancesca commented on GitHub:

@anihm136 how much high the value must be set?

@paolafrancesca commented on GitHub: @anihm136 how much high the value must be set?
Author
Owner

@kugi83 commented on GitHub:

Hey can I take this issue?

@kugi83 commented on GitHub: Hey can I take this issue?
Author
Owner

@jimmybrancaccio commented on GitHub:

Looks good now @aspacca and @kugiyasan Thank you both! ❤️

@jimmybrancaccio commented on GitHub: Looks good now @aspacca and @kugiyasan Thank you both! ❤️
Author
Owner

@kugi83 commented on GitHub:

Oops sorry! I made the PR asap, @aspacca

@kugi83 commented on GitHub: Oops sorry! I made the PR asap, @aspacca
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#149