Restrict Attachments by Mimetype

Last modified by Eleni Cojocariu on 2026/09/30 17:42

Steps

Turn an attachment down for its file type across the whole wiki, using the accept and refuse mimetype lists the Attachment Validation Application adds to the administration.

  1. Select "Administer Wiki" and open "Attachments Restriction", in the "Content" category.

    allowed-blocked-mimetypes.png

  2. Fill "Allowed Mimetypes" with the mimetypes you accept, or "Blocked Mimetypes" with the ones you refuse, separated by commas. Write them in lower case, and put a single * where any text is allowed.
    text/plain,image/*,*/pdf
  3. Select "Save". The field comes back with the same list separated by |, which XWiki reads exactly as the commas you typed.
  4. Attach a file of a refused type to a Page the restriction covers. The upload is turned down, and the notice names the mimetype XWiki found.

    attachment-upload-rejected.png

FAQ

Where else can the restriction be set?

On one Page tree, and across a whole farm, in xwiki.properties. The Page being written to wins over the wiki, and the wiki over the file.

How is a mimetype matched against the lists?

A pattern matches a mimetype in full unless it holds a *, which stands for any text in that one place, and only the first * is a joker: a pattern is neither a glob nor a regular expression. Where both lists are filled, an attachment has to be in the allowed list and out of the blocked list, so a mimetype named in both is refused.

Can a file get past the restriction by being renamed?

No. Apache Tika detects the mimetype from the contents of the file and uses the name only to narrow a type the contents leave open, so giving an executable a .txt extension does not make it plain text to the check.

Is the restriction enforced in the browser only?

No. The browser turns the file down before sending it, going by the type the operating system reports, and XWiki runs its own check once the file arrives. A client that skips the first one has the upload turned down all the same.

Is anything restricted before I fill a list?

No. Both lists are empty on a new wiki, so every mimetype is accepted until one of them is filled.

More

To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.

Related

Get Connected