Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54067 closed enhancement (invalid)

Filenames shouldn't hold dots

Reported by: anonymized_14808221's profile anonymized_14808221 Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Media Keywords:
Focuses: Cc:

Description

When uploading a file (attachment) to WP (posts or else) and said file has dots in its name (like it is the case for Screenshots) then the File URL becomes something like
https://site.tld/wp-content/uploads/Screenshot-2021-09-03-at-13.10.46.png

While that is expected perhaps WP Could check if there are dots in the filename and either replace them by a dash or fully reject the upload.

Dots in the filename create issues when creating download links, for example, where then the downloaded attachment ends up being a format of "46", instead of "png", taken in above example.

It should be great if this can be avoided, as dots in filenames are likely not a good idea to have anyway, but telling that the consumers is rather a exorbitant and almost impossible task.

Of course we could validate uploads on our own, however I think it would be a good thing to have directly in the media uploader.

Happy to stand corrected :)

Change History (4)

#1 @joyously
3 years ago

It sounds like the problem is in the use of the name, not the upload. A dot is a valid character and limiting their usage now would not solve anything for existing files with dots.
Is your example of a download getting the wrong extension from core or a plugin?

#2 @anonymized_14808221
3 years ago

  • Keywords 2nd-opinion removed
  • Resolution set to invalid
  • Status changed from new to closed

I am not relying on plugins, however, you are right that there was an error in my approach.

I used <a download="'.$filename.'" href="'.$fileurl.'">handle</a> (where of course the $vars are previously dynamically populated).
That generates a link where the download attribute has a couple dots too many in it, and thus creating a downloaded filename of file.name.more.dots

By changing that to use another, non dotted filename (stripping them prior to usage) resolves the issue.

Sorry the unnecessary trac ticket.

Closed as non-issue.

#3 @desrosj
3 years ago

  • Milestone Awaiting Review deleted

Changing the resolution to invalid as that's the default catch all resolution. fixed is reserved for closed tickets where a change was made to fix the problem.

#4 @desrosj
3 years ago

Oops, apologies! invalid already was the resolution. I had misread the ticket.

Note: See TracTickets for help on using tickets.