Details
-
Bug
-
Resolution: Unresolved
-
Neutral
-
None
-
3.5.3
-
None
-
None
Description
Steps to reproduce
- Upload an image without an extension in its filename
- See that the image in the UI gets a name with a dot at end.
- Select a component with the ability to pick an image.
- Search for the image, see that both in the list and preview the image is broken.
Expected results
The image is shown
Actual results
Broken image image is shown.
In jcr it can be seen that the filename property ends with a . (no extension) and that extension is present but empty (see development notes on the impact).
Exception in the logs:
java.lang.IllegalArgumentException: Could not parse '' at com.google.common.net.MediaType.parse(MediaType.java:1078) ~[guava-31.1-jre.jar:?] at info.magnolia.imaging.AbstractImageStreamer.getMediaType(AbstractImageStreamer.java:53) ~[magnolia-imaging-3.5.3.jar:?] at info.magnolia.imaging.DefaultImageStreamer.serveImage(DefaultImageStreamer.java:70) ~[magnolia-imaging-3.5.3.jar:?]
Workaround
Reupload with an extension in the filename or add extension to the filename and set the extension through JCR browser.
Development notes
The problem has multiple parts:
- The check for a missing extension in info.magnolia.imaging.DefaultImageGenerator#getOutputFormat does not take into account an empty extension (which is the case here) but only a missing (null) property. This sets the outputformat to empty string causing the image generation to fail as no mediatype can be determined.
- The image extension depends purely on the filename, although mimetype information is available (see info.magnolia.ui.editor.JcrBinaryHelper#createBinary)
- Existing images with a filename that has no extension will have their extension set to empty string on save and if the filename has no dot at the end it will be added.
Checklists
Acceptance criteria