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

Improve attachment filename extraction #72

Merged
merged 4 commits into from
Mar 24, 2023

Conversation

njohner
Copy link
Contributor

@njohner njohner commented Mar 17, 2023

We were already handling the case where filename returned by msg.get_filename() returned a cropped version of the filename. In that case we took the filename from the last filename parameter of the content-disposition headers. It now turns out that sometimes msg.get_filename() returns a normalized version of the filename, e.g. without umlauts. This is also not what we want and using the last filename parameter of the content-disposition headers would also fix the issue. So it seems we can always take the last one when there are several.

Note that I changed/fixed a few other things:

  • We pretended to look at the content-disposition header when we were actually looking at the content-type header.
  • We now search for the "filename" parameter in the header case-insensitive. This is also what python's Message.get_param does.

For https://4teamwork.atlassian.net/browse/CA-5456

Niklaus Johner added 3 commits March 17, 2023 14:53
@njohner njohner force-pushed the nj/CA-5456/improve_attachment_filenames branch from f4a18fe to 8c3df41 Compare March 17, 2023 15:01
@njohner njohner marked this pull request as ready for review March 17, 2023 15:06
@njohner njohner force-pushed the nj/CA-5456/improve_attachment_filenames branch from 8c3df41 to 7c052ff Compare March 17, 2023 15:07
@njohner njohner requested a review from a team March 17, 2023 15:15
Copy link
Member

@phgross phgross left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@njohner njohner merged commit d99694e into master Mar 24, 2023
@njohner njohner deleted the nj/CA-5456/improve_attachment_filenames branch March 24, 2023 07:56
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