Uploaded image for project: 'Imaging'
  1. Imaging
  2. MGNLIMG-247

Uploading an image without an extension in its filename results in broken images in the UI and webpages

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Neutral
    • None
    • 3.5.3
    • None
    • None

    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.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              rico.jansen Rico Jansen
              DeveloperX
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Checklists

                  Bug DoR
                  Task DoD