Changing the title of an attachment on Confluence to just blank spaces doesn't result on an error and commits the change on the database

XMLWordPrintable

    • 7
    • Severity 3 - Minor
    • 0

      Issue Summary

      If a user changes the attachment title to just blank spaces, Confluence accepts the change and it is committed to the database.
      Committing this change results on some undesired state for an attachment file as below:

      • The name of the attachment on the Attachments screen doesn't exist, making it impossible to open the file without additional steps.
      • Trying to insert the file to the page results on an error.
        • On the UI the user sees a message as "There was an error processing the request".
        • On the application logs the administrator may find an entry similar to the below.
          2021-11-01 23:06:04,826 WARN [http-nio-27130-exec-3] [content.render.xhtml.DefaultFormatConverter] validateAndConvertToStorageFormat XhtmlException converting editor format to storage format. Turn on debug level logging to see editor format data.
           -- referer: http://localhost:27130/c7130/pages/resumedraft.action?draftId=360479&draftShareId=a662c9c7-9c2e-419c-bcff-8ebab03efb03& | url: /c7130/rest/api/content/360478 | traceId: 7776b4b3468ab1d9 | userName: admin
          com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while transforming editor format to storage format (filename cannot be null or blank.)
          	at com.atlassian.confluence.content.render.xhtml.editor.EditorXhtmlTransformer.transform(EditorXhtmlTransformer.java:58)
          	at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:33)
          	at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:33)
          	at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:39)
          	at com.atlassian.confluence.content.render.xhtml.editor.DefaultEditorConverter.convert(DefaultEditorConverter.java:37)
          (...)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          	at java.lang.Thread.run(Thread.java:748)
          Caused by: java.lang.IllegalArgumentException: filename cannot be null or blank.
          	at com.atlassian.confluence.content.render.xhtml.model.resource.identifiers.AttachmentResourceIdentifier.<init>(AttachmentResourceIdentifier.java:17)
          	at com.atlassian.confluence.content.render.xhtml.editor.macro.MacroParameterTypeParserImpl.resolveFullAttachment(MacroParameterTypeParserImpl.java:308)
          
      • If the file was being used within a view-file macro in a page, before the file name was changed to spaces, then reverting it won't automatically change the page storage format, breaking the view-file macro.
      • If an export is created on this condition, then an import fails as reported on bug CONFSERVER-74538.

      Steps to Reproduce

      1. Create a new page with sample content and publish it.
      2. Go to the Attachments screen of that page.
      3. Upload a new file as an attachment.
      4. Click on the Properties button related to this attachment.
      5. On the File Name field, delete the current name and add just a space.
      6. Click on Save.

      Expected Results

      The modification isn't saved and the user receives and information on the UI explaining a file name with just spaces isn't allowed.
      The modification isn't committed to the database.

      Actual Results

      Confluence accepts the modification of the file name to just blank spaces, saving and committing the change to the database.

      Workaround

      Confluence administrators can run a SQL query to identify attachments on which the file name is composed of only blank spaces and then chank.

      MySQL
      select c.* from CONTENT c where c.contenttype = 'ATTACHMENT' and c.lowertitle REGEXP '[[:space:]]+';
      
      Other DBs
      select c.* from content c where c.contenttype = 'ATTACHMENT' and c.lowertitle ~ '[[:space:]]+';
      

            Assignee:
            Anshul Chokhani
            Reporter:
            Thiago Masutti (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: