As MW detects the MIME type of the file as it is being uploaded, it should not rely on the uploader to provide a file extension. Rather the file type should be set automatically by the software. Any extension detected in the name should be automatically removed.
For example if Cheese.JPEG is uploaded, but the MIME type is PNG, the file should be named Cheese.png, and not Cheese.JPEG.png. If that MIME type is correct, it should simply be named Cheese.jpg. This should also create a notice for the uploader, so they don't lose track of their uploaded file.
Obviously this will not fix existing issues mentioned in the first two bugs, but it will prevent future issues.
T34660: File extensions for the same file type should not allow variations of a file name (File:X.jpg, File:X.jpeg, File:X.JPG should all refer to the same file)
T31284: Upload form should change file extensions to the canonical form automatically (lowercase, jpeg→jpg etc.)
T213484: Normalize file extensions (capital vs small letters; jpg vs jpeg) for new uploads on Commons
T144593: File extension changes automatically while moving ogg audio file on Commons, caused by a gadget