[MGNLIMG-247] Uploading an image without an extension in its filename results in broken images in the UI and webpages Created: 04/Aug/22  Updated: 26/Sep/22

Status: Open
Project: Imaging
Component/s: None
Affects Version/s: 3.5.3
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Rico Jansen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2022-08-04 at 11.53.26 .png     PNG File Screenshot 2022-08-04 at 11.54.51 .png    
Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Team: DeveloperX

 Description   

Steps to reproduce

  1. Upload an image without an extension in its filename
  2. See that the image in the UI gets a name with a dot at end.
  3. Select a component with the ability to pick an image.
  4. 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:

  1. 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.
  2. The image extension depends purely on the filename, although mimetype information is available (see info.magnolia.ui.editor.JcrBinaryHelper#createBinary)
  3. 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.


 Comments   
Comment by Rico Jansen [ 05/Aug/22 ]

Fix: https://git.magnolia-cms.com/projects/MODULES/repos/imaging/pull-requests/48/overview

This only fixes the image rendering, not the fact that the extension is empty.

Generated at Mon Feb 12 02:13:42 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.