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

file-server returns 500 when filename contains some special characters #4923

Closed
lonble opened this issue Jul 30, 2022 · 3 comments · Fixed by #4948
Closed

file-server returns 500 when filename contains some special characters #4923

lonble opened this issue Jul 30, 2022 · 3 comments · Fixed by #4948
Assignees
Labels
bug 🐞 Something isn't working in progress 🏃‍♂️ Being actively worked on
Milestone

Comments

@lonble
Copy link

lonble commented Jul 30, 2022

I have a file named "%@.exe" and when I use file-server --browse to view the directory everything is OK. While I click on this file to download it, Caddy returns 500.

In the log, I found this:

invalid URL escape "%@."

After testing, there is no problem with nginx.

@mholt
Copy link
Member

mholt commented Jul 30, 2022

Thanks for opening an issue! We'll look into this.

It's not immediately clear to me what is going on, so I'll need your help to understand it better.

Ideally, we need to be able to reproduce the bug in the most minimal way possible. This allows us to write regression tests to verify the fix is working. If we can't reproduce it, then you'll have to test our changes for us until it's fixed -- and then we can't add test cases, either.

I've attached a template below that will help make this easier and faster! This will require some effort on your part -- please understand that we will be dedicating time to fix the bug you are reporting if you can just help us understand it and reproduce it easily.

This template will ask for some information you've already provided; that's OK, just fill it out the best you can. 👍 I've also included some helpful tips below the template. Feel free to let me know if you have any questions!

Thank you again for your report, we look forward to resolving it!

Template

## 1. Environment

### 1a. Operating system and version

```
paste here
```


### 1b. Caddy version (run `caddy version` or paste commit SHA)

```
paste here
```


### 1c. Go version (if building Caddy from source; run `go version`)

```
paste here
```


## 2. Description

### 2a. What happens (briefly explain what is wrong)




### 2b. Why it's a bug (if it's not obvious)




### 2c. Log output

```
paste terminal output or logs here
```



### 2d. Workaround(s)




### 2e. Relevant links




## 3. Tutorial (minimal steps to reproduce the bug)




Instructions -- please heed otherwise we cannot help you (help us help you!)

  1. Environment: Please fill out your OS and Caddy versions, even if you don't think they are relevant. (They are always relevant.) If you built Caddy from source, provide the commit SHA and specify your exact Go version.

  2. Description: Describe at a high level what the bug is. What happens? Why is it a bug? Not all bugs are obvious, so convince readers that it's actually a bug.

    • 2c) Log output: Paste terminal output and/or complete logs in a code block. DO NOT REDACT INFORMATION except for credentials.
    • 2d) Workaround: What are you doing to work around the problem in the meantime? This can help others who encounter the same problem, until we implement a fix.
    • 2e) Relevant links: Please link to any related issues, pull requests, docs, and/or discussion. This can add crucial context to your report.
  3. Tutorial: What are the minimum required specific steps someone needs to take in order to experience the same bug? Your goal here is to make sure that anyone else can have the same experience with the bug as you do. You are writing a tutorial, so make sure to carry it out yourself before posting it. Please:

    • Start with an empty config. Add only the lines/parameters that are absolutely required to reproduce the bug.
    • Do not run Caddy inside containers.
    • Run Caddy manually in your terminal; do not use systemd or other init systems.
    • If making HTTP requests, avoid web browsers. Use a simpler HTTP client instead, like curl.
    • Do not redact any information from your config (except credentials). Domain names are public knowledge and often necessary for quick resolution of an issue!
    • Note that ignoring this advice may result in delays, or even in your issue being closed. 😞 Only actionable issues are kept open, and if there is not enough information or clarity to reproduce the bug, then the report is not actionable.

Example of a tutorial:

Create a config file:
{ ... }

Open terminal and run Caddy:

$ caddy ...

Make an HTTP request:

$ curl ...

Notice that the result is ___ but it should be ___.

@mholt mholt added needs info 📭 Requires more information bug 🐞 Something isn't working and removed needs info 📭 Requires more information labels Jul 30, 2022
@mholt
Copy link
Member

mholt commented Aug 4, 2022

I've been able to reproduce this and I think I know the cause of the problem. We might be checking the escaping on r.URL.Path instead of r.URL.RawPath. I will need to verify that it is correct to use RawPath instead.

@mholt mholt added this to the v2.5.3 milestone Aug 4, 2022
@mholt mholt added the in progress 🏃‍♂️ Being actively worked on label Aug 9, 2022
@mholt mholt self-assigned this Aug 9, 2022
mholt added a commit that referenced this issue Aug 10, 2022
Expected for path matching and rewriting. Fixes #4923.
@mholt
Copy link
Member

mholt commented Aug 10, 2022

This ended up being more complex than I thought (after going down the rabbit hole), and the fix is now working in #4948.

@mholt mholt modified the milestones: v2.6.0-beta.1, v2.6.0 Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working in progress 🏃‍♂️ Being actively worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants