Opened 11 years ago

Closed 11 years ago

#426 closed improvement (fixed)

Ticket Download, file names encoded IE 11

Reported by: Trevor.Anderson Owned by:
Priority: minor Milestone: 6.8.4
Component: Core Version: 6.8.3
Keywords: Cc:

Description

Using Community LogicalDoc? 6.8.3;
When downloading documents using "Send as Document Ticket" emails via IE 11 the 'Content-Disposition' header syntax appears to be incorrect.
Looking at TicketDownload?.java of component 'logicaldoc-webapp' the 'SetContentDisposition?' function does not support IE11 because User-agent string no longer contains "MSIE". Using the work around found else where in the full project source testing for "Trident" and "Windows" a workaround was created that worked for me, and I wanted to highlight and share with the valuable contributors and authors of this fantastic product.

Work around used:

      /**
       * Sets the correct Content-Disposition header into the response
       */
      private static void setContentDisposition(HttpServletRequest request, HttpServletResponse response, String filename)
                      throws UnsupportedEncodingException {
              // Encode the filename
              String userAgent = request.getHeader("User-Agent");
              String encodedFileName = null;
              if (userAgent.contains("MSIE") || userAgent.contains("Opera") || userAgent.contains("Safari") || (userAgent.contains("Trident") && userAgent.contains("Windows"))){
                      encodedFileName = URLEncoder.encode(filename, "UTF-8");
                      encodedFileName = encodedFileName.replace("+", "%20");
              } else {
                      encodedFileName = "=?UTF-8?B?" + new String(Base64.encodeBase64(filename.getBytes("UTF-8")), "UTF-8")
                                      + "?=";
              }
              response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");
      }

Change History (1)

comment:1 Changed 11 years ago by car031

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.