Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-77727

Adopt a consistent URL encoding for attachments

XMLWordPrintable

    • 0
    • 3
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Our documentation at Upload a file warns that we should not use special characters on the name of the file:


      Avoid using special characters in page or attachment names, as the page or attachment may not be found by Confluence search and may cause some Confluence functions to behave unexpectedly.

      However, we do not validate the file name when attaching to a page, so users might upload files with special characters. If these characters are not properly encoded using the URL encoding (percent-encoding), the links to the attachments might be invalid and return HTTP error 400 (Bad Request or Not found error).

       

      The recommended Special characters to be URL encoded (percent-encoding) are: ':', '/', '?', '#', '[', ']', '@', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', as well as '%' itself. Other characters don't need to be encoded, though they could (Reference: https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding)

      Testing the upload of some files using these characters, we could observe that the solution applied is following a character-per-character basis.
      Some characters are URL-encoded, others are replaced when uploading or downloading, and some are URL encoded but the information retrieved by the REST API Get Page By ID shows a different encoding (see table below for some samples).

      Goal: It would avoid many issues if the link always uses URL-encoding as a pattern for the attachments.

       

      Test:

      char Attachment URL Downloaded file Get page by ID notes
      ! (%21) x/download/attachments/26673219/a!a.jpg?api=v2 a!a.jpg a!a.jpg not encoded
      " (%22) x/download/attachments/26673219/x%22x.jpg?api=v2 a_a.jpg x%22x.jpg replaced
       "#" (%23) x/download/attachments/26673219/a%23a.jpg?api=v2 a#a.jpg a%23a.jpg
      $ (%24) x/download/attachments/26673219/a$a.jpg?api=v2 a$a.jpg a$a.jpg not encoded
      % (%25) x/download/attachments/26673219/a%25a.jpg?api=v2 a%a.jpg a%25a.jpg
      & (%26) x/download/attachments/26673219/a%26a.jpg?api=v2 a&a.jpg a& amp;a.jpg CONFCLOUD-77723
      ' (%27) x/download/attachments/26673219/a%27%20a.jpg?api=v2 a'a.jpg a'a.jpg different encoding
      ( (%28) x/download/attachments/26673219/a(a)a.jpg?api=v2 a(a)a.jpg a(a)a.jpg not encoded
      "*" (%2A) x/download/attachments/26673219/a*a.jpg?api=v2 a_a.jpg a*a.jpg replaced and not encoded
      + (%2B) x/download/attachments/26673219/a%2Ba.jpg?api=v2 a+a.jpg a+a.jpg different encoding
      / (%2F) x/download/attachments/26673219/y:y.jpg?api=v2 a_a.jpg y:y.jpg replaced twice
      : (%3A) x/download/attachments/26673219/a:a.jpg?api=v2 a_a.jpg a:a.jpg replaced and not encoded
      ; (%3B) x/download/attachments/26673219/a;a.jpg?api=v2 Error 400 a;a.jpg Error 400 CONFCLOUD-74200
      \ (%5C) x/download/attachments/26673219/a%5Ca.jpg?api=v2 Error 400 a%5Ca.jpg Error 400 CONFCLOUD-74200

              Unassigned Unassigned
              imurakami@atlassian.com Murakami [Atlassian Support]
              Votes:
              8 Vote for this issue
              Watchers:
              14 Start watching this issue

                Created:
                Updated: