You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2008/06/19 23:28:45 UTC

svn commit: r669705 - /myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java

Author: mcooper
Date: Thu Jun 19 14:28:45 2008
New Revision: 669705

URL: http://svn.apache.org/viewvc?rev=669705&view=rev
Log:
TRINIDAD-1128 - Safari support in FileDownloadActionListener

Thanks Kamran for his patch.
FileDownLoadActionListener needs to use UTF-8 encoding for file names in Safari.

Modified:
    myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java

Modified: myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java?rev=669705&r1=669704&r2=669705&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java (original)
+++ myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/listener/FileDownloadActionListener.java Thu Jun 19 14:28:45 2008
@@ -101,13 +101,16 @@
           hsr.setContentType(contentType);
         if (filename != null)
         {
-          boolean isIE = false;
+          // check for supported user agents. Currently IE, Gecko, and WebKit.
+          // IE and WebKit use UTF-8 encoding.
+          boolean isGecko = true;
           Map<String, String> headers = context.getExternalContext().getRequestHeaderMap();
-          if (headers.get("User-Agent").contains("MSIE"))
-            isIE = true;
+          String agentName = headers.get("User-Agent").toLowerCase();
+          if (agentName.contains("msie") || agentName.contains("applewebkit") || agentName.contains("safari"))
+            isGecko = false;
           // boolean isIE = CoreRenderer.isIE(RenderingContext.getCurrentInstance());
           hsr.setHeader("Content-Disposition",
-                        "attachment; filename=" + MimeUtility.encodeHTTPHeader(filename, isIE));
+                        "attachment; filename=" + MimeUtility.encodeHTTPHeader(filename, !isGecko));
         }
         MethodExpression method = getMethod();
         OutputStream out = new BufferedOutputStream(hsr.getOutputStream());