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

Attachment name used in temporary local file leads to invalid filenames #1551

Closed
jwhitlock opened this issue Feb 17, 2022 · 0 comments · Fixed by #1553
Closed

Attachment name used in temporary local file leads to invalid filenames #1551

jwhitlock opened this issue Feb 17, 2022 · 0 comments · Fixed by #1553
Labels
🐛 bug Something isn't working

Comments

@jwhitlock
Copy link
Member

When an attachment exceeds 150KB, it is written to disk rather than held in memory:

attachment = SpooledTemporaryFile(
max_size=150*1000, # 150KB max from SES
suffix=extension,
prefix=os.path.splitext(fn)[0]
)

The prefix and suffix come from the attachment name, which is user-provided and may not result in a valid filename, and an error when the contents are written to disk.

We should not base the filename on text from the incoming email, and should double-check that these files are closed at the end of the request to free disk space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant