-
Notifications
You must be signed in to change notification settings - Fork 60
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 name too long when parsing attachments #45
Comments
Any new on this issue? |
Sorry, must have missed this. Can you provide the source of the email, or, even better, add a PR with a test case? |
Hi @derickr , I've solved this in my fork using this patch:
I don't have test email, sorry. |
Is this still a live issue for you? |
I'm using an old version of this library, but I have the same problem. If you use the filename of a user-provided email attachment, it might be too long. One solution is to cut it to 250 characters, like @speller does. Why are we trying to use the original filename (which is user-provided data)? We have to extract it (from "Content-Disposition" or "Content-Type"), it has to be cleaned by "unsafe characters", and then we still might have the problem that filenames are too long. Why not just use a random filename? As far as I can see, the filename is not important. Maybe this code solves all problems?
You can remove 20 lines of code, the filename is unique, no user-data involved, it's not too long, it's not too short, and everybody is happy :-) |
I've fixed this as part of #83. |
Hi @derickr , Thanks for the commit, but I think the problem is not fixed yet. I just ran the tests on my Windows machine, and I got:
The space in the test "testVarious13" still is not working. You are now using a whitelist: White searching for "allowed filenames on Windows" I found this: My suggestion is still: Don't use the user-provided string, and just generate a random filename like this for example: Or you also have to remove the dot and the space from the character whitelist. |
I have the following repeated error when parsing email:
Please fix attachment file handling.
The text was updated successfully, but these errors were encountered: