Skip to content

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

Closed

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.

Activity

  1. added this to the 6.0.0 milestone on Jun 30, 2018
  2. self-assigned this
    on Jun 30, 2018
  3. added a commit that references this issue on Jun 30, 2018
  4. removed their assignment
    on Aug 1, 2018
  5. bbottema commented on Dec 18, 2019

    @bbottema
    OwnerAuthor

    Released in 6.0.0-rc1.

  6. bbottema commented on Jan 24, 2020

    @bbottema
    OwnerAuthor

    6.0.0 has released as well, finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions