XWiki Platform
  1. XWiki Platform
  2. XWIKI-9611

Image attachments don't appear in the PDF export if their URL contains special characters

    Details

    • Tests:
      Unit
    • Development Priority:
      High
    • Difficulty:
      Easy
    • Documentation:
      N/A
    • Similar issues:

      Description

      It's enough to have a space character in the name of the space, page or image file.

        Issue Links

          Activity

          Hide
          Marius Dumitru Florea added a comment -

          I couldn't reproduce the behaviour locally but debugging the PDF export code shows that for an image attachment with this reference

          [[image:My Space.My Page@my image.png]]
          

          the URL generated by the PDF URL factory is

          /xwiki/bin/download/My+Space/My+Page/my+image.png
          

          which is decoded by PDFURIResolver, our custom URI resolver that is used with FOP, into

          /xwiki/bin/download/My Space/My Page/my image.png
          

          and is not found in the map of (URL, AttachmentReference) build by the PDF URL factory, because the key is always an encoded URL.

          It seems this is a regression introduced by XWIKI-9437. Starting with 5.2RC1 the URLs created through the URL factory are encoded.

          Show
          Marius Dumitru Florea added a comment - I couldn't reproduce the behaviour locally but debugging the PDF export code shows that for an image attachment with this reference [[image:My Space.My Page@my image.png]] the URL generated by the PDF URL factory is /xwiki/bin/download/My+Space/My+Page/my+image.png which is decoded by PDFURIResolver , our custom URI resolver that is used with FOP, into /xwiki/bin/download/My Space/My Page/my image.png and is not found in the map of (URL, AttachmentReference) build by the PDF URL factory, because the key is always an encoded URL. It seems this is a regression introduced by XWIKI-9437 . Starting with 5.2RC1 the URLs created through the URL factory are encoded.
          Hide
          Marius Dumitru Florea added a comment -

          I'm going to remove the code that decode the passed URI from the PDFURIResolver. See also Thomas Mortagne's comment when this code was added.

          Show
          Marius Dumitru Florea added a comment - I'm going to remove the code that decode the passed URI from the PDFURIResolver . See also Thomas Mortagne 's comment when this code was added.
          Hide
          Vincent Massol added a comment -

          Sorry about that. Seems XWIKI-9437 actually caused a lot of regressions...

          BTW I didn't realize that httpServletResponse.encodeURL() was also encoding the URLs (I thought it was only adding the jsessionid if need be).

          Show
          Vincent Massol added a comment - Sorry about that. Seems XWIKI-9437 actually caused a lot of regressions... BTW I didn't realize that httpServletResponse.encodeURL() was also encoding the URLs (I thought it was only adding the jsessionid if need be).

            People

            • Assignee:
              Marius Dumitru Florea
              Reporter:
              Marius Dumitru Florea
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Date of First Response: