-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fix for files with %
in filename
#452
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -149,7 +149,7 @@ const dirList = { | |||||
route = path.normalize(path.join(route, '..')) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we change it to? Maybe on top of the file we do:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might work but it's not part of the fix for this PR. See #452 (comment) |
||||||
} | ||||||
return { | ||||||
href: path.join(prefix, route, entry.name).replace(/\\/gu, '/'), | ||||||
href: encodeURI(path.join(prefix, route, entry.name).replace(/\\/gu, '/')), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder, can we avoid this regex? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regex was already there. I tried switching to |
||||||
name: entry.name, | ||||||
stats: entry.stats, | ||||||
extendedInfo: entry.extendedInfo | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
100% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your comment: we uri decode path in send? How about apply a change in @fastify/send , like pass decodeUri option in options, by default true for backwards compat and we set it here to false and then we dont need to encodeURI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs of
@fastify/send
is seems the path passed is intended to be URL-encoded:https://github.com/fastify/send?tab=readme-ov-file#api
While I agree that this seems like a little extra overhead it looks like the
@fastify/send
API was not being used correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe send could be refactored to do what Uzlopak suggests