#106890Replacing a file in filelist with different file extension
Description
Replacing an existing file with one of a different file extension is not possible anymore but totally valid, e.g. jpg with a png
current error:
> Mime-type “image/jpeg” not allowed for file extension “png”.
Reviews 3
Related issues 2
History 1324
-
Garvin Hicking changed parent task #106772 <span data-processor="relativetime" data-value="2025-06-16T10:12:54+00:00" > 06/16/25, 10:12 </span>
-
Georg Ringer commented <span data-processor="relativetime" data-value="2025-06-16T13:10:03+00:00" > 06/16/25, 13:10 </span>
1st: Typical usecase is:
- Client provides somewhere an image of a product as jpg
- The image is used on multiple images
- The quality of the jpg is bad, now a png is provided and all usages need to be changed
2nd: Sometimes I even got clients how changed a pdf to a zip and vice versa as those files are used for creating downloads.
3rd: What also now not working is renaming a file, like a test.txt to test.csv. Just some not so helpful message “Resource consistency check failed” is shown -
Markus Klein commented <span data-processor="relativetime" data-value="2025-06-16T13:42:14+00:00" > 06/16/25, 13:42 </span>
I’m fully with Georg here. Users have the need to replace an image at all places. (Sometimes even for legal reasons.)
Of course there might be scenarios where replacing a file with some other mime-type file can cause issues.
But I have a hard time weighing “absolute security by tool” with “practical needs” here.
(I tend to lean towards the second.) -
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-06-16T14:05:45+00:00" > 06/16/25, 14:05 </span>
Could we just validate the “new file” against the allowed mimetypes, and not do comparison of oldmime == newmime? So if I want to replace an image with a pdf, as long as the pdf is not a forbidden filetype&mime mapping, it could go through?
(If not by default, at least with a feature.backend.allowHotMimeReplacement switch?)
-
Oliver Hader commented <span data-processor="relativetime" data-value="2025-06-17T08:16:51+00:00" > 06/17/25, 08:16 </span>
The problem in the user interface is, that “replace file” actually performs two operations:
- replacing the existing file object with the uploaded contents (e.g.
file.pdfgets new contents ofimage/png→ which obviously fails) - renaming the existing file object to match the uploaded file (e.g.
file.pdfwith contents ofimage/pngto be renamed tofile.png)
For solving this, a new storage method has to be introduced that reflects both of the mentioned operations.
This is not a discussion about security, but a discussion about poor API design in the file abstraction layer. - replacing the existing file object with the uploaded contents (e.g.
-
Gerrit Code Review pushed patch set 1 for main to change 89740 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2025-06-17T10:13:35+00:00" > 06/17/25, 10:13 </span> -
Oliver Hader commented <span data-processor="relativetime" data-value="2025-06-17T10:18:54+00:00" > 06/17/25, 10:18 </span>
I’ve added a WIP patch which combines the replace-and-rename FAL operation.
Besides that, the handling for “keep the current filename” has been adjusted (keeping
whatever.pdffor animage/pngcontents already would have failed in a browser, the new behavior adjusts the file extension, resulting inwhatever.pngfor this example). -
Denis Mir commented <span data-processor="relativetime" data-value="2025-07-02T12:03:03+00:00" > 07/02/25, 12:03 </span>
One additional use case is that an old “doc” file gets replace by a “docx” file. This happens pretty regularly for some of our customers.
-
Mathias Brodala commented <span data-processor="relativetime" data-value="2025-07-02T13:03:51+00:00" > 07/02/25, 13:03 </span>
Denis Mir wrote in #note-10:
> One additional use case is that an old “doc” file gets replace by a “docx” file. This happens pretty regularly for some of our customers.That’s the same usecase, a completely different file extension and completely different MIME type. Even if they looks similar to humans. ;-)
-
Gerrit Code Review pushed patch set 2 for main to change 89740 <span data-processor="relativetime" data-value="2025-07-03T09:15:55+00:00" > 07/03/25, 09:15 </span>
-
Oliver Hader changed Related to #107027 <span data-processor="relativetime" data-value="2025-07-03T18:53:04+00:00" > 07/03/25, 18:53 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 89740 <span data-processor="relativetime" data-value="2025-07-03T19:13:17+00:00" > 07/03/25, 19:13 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 89740 <span data-processor="relativetime" data-value="2025-07-03T20:34:34+00:00" > 07/03/25, 20:34 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 89740 <span data-processor="relativetime" data-value="2025-07-07T16:16:33+00:00" > 07/07/25, 16:16 </span>
-
Garvin Hicking changed Related to #107053 <span data-processor="relativetime" data-value="2025-07-07T18:44:45+00:00" > 07/07/25, 18:44 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 90012 <span data-processor="relativetime" data-value="2025-07-08T07:47:22+00:00" > 07/08/25, 07:47 </span>
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 90014 <span data-processor="relativetime" data-value="2025-07-08T07:52:06+00:00" > 07/08/25, 07:52 </span>
-
Gerrit Code Review pushed patch set 2 for 12.4 to change 90014 <span data-processor="relativetime" data-value="2025-07-08T08:08:48+00:00" > 07/08/25, 08:08 </span>
-
Gerrit Code Review pushed patch set 2 for 13.4 to change 90012 <span data-processor="relativetime" data-value="2025-07-08T08:24:36+00:00" > 07/08/25, 08:24 </span>
-
Gerrit Code Review pushed patch set 3 for 12.4 to change 90014 <span data-processor="relativetime" data-value="2025-07-08T08:25:07+00:00" > 07/08/25, 08:25 </span>
-
Gerrit Code Review pushed patch set 4 for 12.4 to change 90014 <span data-processor="relativetime" data-value="2025-07-08T08:33:16+00:00" > 07/08/25, 08:33 </span>
-
Oliver Hader commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-07-08T08:45:09+00:00" > 07/08/25, 08:45 </span>Applied in changeset commit:cf227b18e205a3720599f07ac98a8747c7008398.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:21:25+00:00" > 12/02/25, 14:21 </span>
What is the “valid” use-case for replacing contents having the type
image/jpegto a file with.pngextension?Probably I’m overlooking something here. Please provide a step by step example to understand the scenario. Thanks!