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

Sanitize filename #4635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Sanitize filename #4635

wants to merge 1 commit into from

Conversation

nicodh
Copy link
Member

@nicodh nicodh commented Feb 13, 2025

#skip-changelog

@nicodh
Copy link
Member Author

nicodh commented Feb 13, 2025

This does not remove any special characters, but avoids path manipulations being passed together with msg.filename

@@ -374,6 +382,8 @@ export async function copyFileToInternalTmpDir(
): Promise<string> {
const sourceFileName = basename(sourcePath)
const sourceDir = dirname(sourcePath)
// make sure fileName includes only a file name, no path or whatever
fileName = basename(normalize(fileName))
Copy link
Member

@ralphtheninja ralphtheninja Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is normalize() needed? Shouldn't basename() be enough?

Copy link
Member Author

@nicodh nicodh Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not sure if basename can be "tricked" if it gets an unexpected argument, while normalize is obviously created for "normalizing" but may be I exagerate...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. Better safe than sorry!

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

Successfully merging this pull request may close these issues.

2 participants