Skip to content

Attachment's file extension overwritten by resource's invalid extension #151

@bbottema

Description

@bbottema

Simple Java Mail tries to use the extension found in the resource name over the provided name. This is to find possible missing or invalid extensions provided manually by looking at the resource itself.

However, this contains a bug where the given extension is overwritten even if the resource's extension is not really an extension at all, in some URL for example:

URL url = new URL("https://booking.skypicker.com/api/v0.1/get_file/1234?file_id=1234&simple_token=abcd1234");
		URLDataSource resource = new URLDataSource(url);
		Email email = EmailBuilder.startingBlank()
				(..)
				.withAttachment("invoice.pdf", resource)
				.buildEmail();

Because of this bug, the invoice.pdf filename is replaced with invoice.pdf.1/get_file/1234?file_id=1234&simple_token=abcd1234.

The current solution is not as smart as realizing .1+rest is not an extension, but it should be smart enough to understand the given filename already has an extension.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions