Drop the extension only if present, by looking at mimetype detected-by-extension.
If the mime is not the default one, it means that the filename has a valid extension, which we want to drop.
Otherwise it's just a filename with some dots, we can use it as is.
BUG: 362690