Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-23340

Velocity error when using a single value in attachment.upload.allowList or blockList

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 17.3.0
    • None
    • Unknown

    Description

      Reproduction steps:

      • Edit xwiki.properties and set a single value in attachment.upload.allowList, e.g.:
        attachment.upload.allowList=text/plain
        
      • Start the wiki
      • Upload a file

      Expected result:

      • There's no error in the wiki and the allow list is properly used to check the type of the uploaded file

      Obtained result:

      • There's an error displayed on top of the wiki
      • It's not possible to upload anything as a javascript error occurs

      Root cause of the stacktrace:

      Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.List (java.lang.String and java.util.List are in module java.base of loader 'bootstrap')
       at org.xwiki.attachment.validation.internal.DefaultAttachmentValidationConfiguration.get(DefaultAttachmentValidationConfiguration.java:144)
       at org.xwiki.attachment.validation.internal.DefaultAttachmentValidationConfiguration.lambda$getPropertyWithFallback$1(DefaultAttachmentValidationConfiguration.java:134)
       at java.base/java.util.Optional.or(Optional.java:313)
       at org.xwiki.attachment.validation.internal.DefaultAttachmentValidationConfiguration.getPropertyWithFallback(DefaultAttachmentValidationConfiguration.java:134)
       at org.xwiki.attachment.validation.internal.DefaultAttachmentValidationConfiguration.getAllowedMimetypes(DefaultAttachmentValidationConfiguration.java:89)
       at java.base/java.util.Optional.map(Optional.java:260)
       at org.xwiki.attachment.validation.AttachmentValidationScriptService.getAllowedMimetypes(AttachmentValidationScriptService.java:63)
      

      Note that the same happen when providing a single value in the attachment.upload.blocklist property.

      Attachments

        Activity

          People

            Unassigned Unassigned
            surli Simon Urli
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: