Uploaded image for project: 'Explorer'
  1. Explorer
  2. EXPLORER-484

Mutualize the code to set attachment header in AmetysResourceReader

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 4.3.0
    • 4.1.0
    • None
    • None
    • 4.3 RC4

      In

      org.ametys.plugins.explorer.resources.readers.AmetysResourceReader.setup(SourceResolver, Map, String, Parameters)
      

      there is a portion of code that set the header to attachment, with the filename

                      String name = _object.getName();
                      String encodedName = null;
                      try
                      {
                          URI uri = new URI(null, null, name, null);
                          encodedName = uri.toASCIIString();
                          // EXPLORER-358 : Fix for Chrome which does not support comma in filename
                          encodedName = encodedName.replaceAll(",", "%2C");
                      }
                      catch (URISyntaxException e)
                      {
                          // do nothing and send no encoded name
                      }
                      
                      name = name.replaceAll("\\\\", "\\\\\\\\");
                      name = name.replaceAll("\\\"", "\\\\\\\"");
                      response.setHeader("Content-Disposition", "attachment; filename=\"" + (encodedName != null ? encodedName : name) + "\"" + (encodedName != null ? ";filename*=UTF-8''" + encodedName : ""));
      

      The exact same code is used in

      org.ametys.plugins.serverdirectory.CheckPathAccessAction._setHeader(String, Response)
      

      It should be mutualized.

       

      Note : in serverdirectory, the character ";" is handled, and not in AmetysResourceReader (at the time of creation of this ticket)

            Unassigned Unassigned
            pgros Pierre Gros (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: