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: bedas's profile bedas Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Media Keywords:
Focuses: Cc:


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

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 @bedas
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

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.