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

🐛 bug: handle url encoded space/values in middleware/filesystem #2246

Closed
wants to merge 1 commit into from

Conversation

Simerax
Copy link
Contributor

@Simerax Simerax commented Nov 29, 2022

Description

Make the filesystem middleware handle url encoded values in the url path.
Main purpose of the change is to handle url encoded space.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • For new functionalities I follow the inspiration of the express js framework and built them similar in usage
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - https://github.com/gofiber/docs for https://docs.gofiber.io/
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (go test -run Test_FileSystem ./middleware/filesystem, normal go test ./... failed before and after my change)
  • If new dependencies exist, I have checked that they are really necessary and agreed with the maintainers/community (we want to have as few dependencies as possible)
  • I tried to make my code as fast as possible with as few allocations as possible
  • For new code I have written benchmarks so that they can be analyzed and improved

Commit formatting:

Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/

@welcome
Copy link

welcome bot commented Nov 29, 2022

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

Thanks for the fix

I think it will affect the performance though

Can you please make a before and after performance measurement and share the result with us

Here is an interesting link with a fasthttp functionality we might use

https://github.com/gofiber/fiber/blob/master/ctx.go#L1717

@ReneWerner87
Copy link
Member

btw have you tested the config setting UnescapePath: true ?

@Simerax
Copy link
Contributor Author

Simerax commented Nov 30, 2022

btw have you tested the config setting UnescapePath: true ?

Looks like this setting fixes the problem. The path gets unescaped. I guess this pr is obsolete then. I think its a little weird that this setting is false by default though. Maybe it would make sense to document this behaviour in the middleware? something like "hey if you serve files with spaces make sure fiber config has UnescapePath set to true"

@ReneWerner87
Copy link
Member

btw have you tested the config setting UnescapePath: true ?

Looks like this setting fixes the problem. The path gets unescaped. I guess this pr is obsolete then. I think its a little weird that this setting is false by default though. Maybe it would make sense to document this behaviour in the middleware? something like "hey if you serve files with spaces make sure fiber config has UnescapePath set to true"

yes more documentation helps here in the case
can you do that?

@Simerax
Copy link
Contributor Author

Simerax commented Nov 30, 2022

see #2247

@Simerax Simerax closed this Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants