In bug 1598216 I'm appending a valid extension when the original one contains illegal characters, so the final file stays usable for the user, and this is coherent with what Save Page As does.
Gijs pointed out that if it just works WebDevs may not care much about fixing those cases, and we put the burden of renaming the file on to users. Replacing the extension directly may be nicer to them.
I noted that replacing the extension may cause name dataloss in some cases, for example "1.imagewithflowers:png" would become "1.png", with a clear naming dataloss.
Anyway all of this is very edge case, so I'm filing this as a follow-up for evaluation.
Note that whatever thing we do, the 2 cases "Save As" on the link and "Save Page As" after opening the link should stay coherent.