roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gango...@apache.org
Subject svn commit: r219493 - in /incubator/roller/branches/roller_1.2: metadata/xdoclet/ src/org/roller/presentation/filters/ src/org/roller/presentation/velocity/
Date Mon, 18 Jul 2005 14:05:09 GMT
Author: gangolli
Date: Mon Jul 18 07:04:52 2005
New Revision: 219493

URL: http://svn.apache.org/viewcvs?rev=219493&view=rev
Log:
Merge of 219426:219427 for ROL-760 to 1.2 branch.

Added:
    incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/CharEncodingFilter.java
      - copied unchanged from r219439, incubator/roller/trunk/src/org/roller/presentation/filters/CharEncodingFilter.java
Modified:
    incubator/roller/branches/roller_1.2/metadata/xdoclet/filter-mappings.xml
    incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/RequestFilter.java
    incubator/roller/branches/roller_1.2/src/org/roller/presentation/velocity/SearchServlet.java

Modified: incubator/roller/branches/roller_1.2/metadata/xdoclet/filter-mappings.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.2/metadata/xdoclet/filter-mappings.xml?rev=219493&r1=219492&r2=219493&view=diff
==============================================================================
--- incubator/roller/branches/roller_1.2/metadata/xdoclet/filter-mappings.xml (original)
+++ incubator/roller/branches/roller_1.2/metadata/xdoclet/filter-mappings.xml Mon Jul 18 07:04:52
2005
@@ -5,18 +5,32 @@
     ******************************************************* -->
 
 <!--
+     NOTE: Wherever "dispatcher" elements are specified in the filter mappings, they are
+     required for Servlet API 2.4 containers, such as Tomcat 5+ and Resin 3+, but should
be
+     commented out for Servlet API 2.3 containers, like Tomcat 4.x and Resin 2.x.
+-->
+
+<!--
 <filter-mapping>
     <filter-name>UrlRewriteFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
 -->
 
-<!-- Map everything to the PersistenceSessionFilter -->
+<!-- Ensures character encoding set to UTF-8 and JSTL and Struts locales are in sync.
+     Note: Any filters preceding this one MUST not cause request parsing. -->
+<filter-mapping>
+    <filter-name>CharEncodingFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+</filter-mapping>
+
+<!-- Map everything to the PersistenceSessionFilter.
+     NOTE: Any filters preceding this one MUST NOT use persistence sessions.-->
 <filter-mapping>
     <filter-name>PersistenceSessionFilter</filter-name>
     <url-pattern>/*</url-pattern>
-    <!-- You must uncomment these two dispatcher lines on Tomcat 5+ and any Servlet API
2.4+ container
-         in order to avoid database connection leaks on the FORWARD dispatch paths. -->
     <dispatcher>REQUEST</dispatcher>
     <dispatcher>FORWARD</dispatcher>
 </filter-mapping>
@@ -64,8 +78,6 @@
 <filter-mapping>
     <filter-name>loginFilter</filter-name>
     <url-pattern>/login.jsp</url-pattern>
-    <!-- You must uncomment these two dispatcher lines on Tomcat 5+ and any Servlet API
2.4+ container
-         in order for RememberMe to work in these environments, because we can reach login.jsp
via FORWARD. -->
     <dispatcher>REQUEST</dispatcher>
     <dispatcher>FORWARD</dispatcher>
 </filter-mapping>

Modified: incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/RequestFilter.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/RequestFilter.java?rev=219493&r1=219492&r2=219493&view=diff
==============================================================================
--- incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/RequestFilter.java
(original)
+++ incubator/roller/branches/roller_1.2/src/org/roller/presentation/filters/RequestFilter.java
Mon Jul 18 07:04:52 2005
@@ -49,40 +49,15 @@
     }
 
     /**
-     * As the first and last filter in the chain, it is necessary that
-     * RequestFilter releases its Roller resources before it returns.
+     * Request filter.
      */
     public void doFilter(
         ServletRequest req, ServletResponse res, FilterChain chain)
         throws IOException, ServletException
     {
-        try
-        {
-            // insure that incoming data is parsed as UTF-8
-            req.setCharacterEncoding("UTF-8");
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            throw new ServletException("Can't set incoming encoding to UTF-8");
-        }
-
-        // keep JSTL and Struts Locale's in sync
+        // NOTE: Setting character encoding and JSTL/Struts locale sync has been moved to
+        // CharEncodingFilter, which is mapped for all URIs in the context.
         HttpSession session = ((HttpServletRequest)req).getSession();
-        if (null != session)
-        {
-            Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
-            if (locale == null)
-            {
-                locale = req.getLocale();
-            }
-            if (req.getParameter("locale") != null)
-            {
-                locale = new Locale(req.getParameter("locale"));
-            }
-            session.setAttribute(Globals.LOCALE_KEY, locale);
-            Config.set(session, Config.FMT_LOCALE, locale);
-        }
-
         HttpServletRequest request = (HttpServletRequest)req;
         HttpServletResponse response = (HttpServletResponse)res;
         Roller roller = RollerContext.getRoller( request );

Modified: incubator/roller/branches/roller_1.2/src/org/roller/presentation/velocity/SearchServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.2/src/org/roller/presentation/velocity/SearchServlet.java?rev=219493&r1=219492&r2=219493&view=diff
==============================================================================
--- incubator/roller/branches/roller_1.2/src/org/roller/presentation/velocity/SearchServlet.java
(original)
+++ incubator/roller/branches/roller_1.2/src/org/roller/presentation/velocity/SearchServlet.java
Mon Jul 18 07:04:52 2005
@@ -1,14 +1,11 @@
 package org.roller.presentation.velocity;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
-
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspFactory;
@@ -39,6 +36,7 @@
 import org.roller.util.StringUtils;
 
 
+
 /**
  * This servlet retrieves (and displays) search results.
  *
@@ -69,6 +67,9 @@
     public Template handleRequest(HttpServletRequest request,
                         HttpServletResponse response, Context ctx) throws Exception
     {
+        // Note: Removed request character encoding here; was too late; it is now set uniformly
in CharEncodingFilter.
+        // See ROL-760.
+
         String enabled = RollerConfig.getProperty("search.enabled");
         if("false".equalsIgnoreCase(enabled))
             this.searchEnabled = false;
@@ -91,20 +92,7 @@
             }
             return outty;
         }
-        
-         // set request Charcter Encoding here, because the SearchServlet
-         // is not preceeded by the RequestFilter
-         mLogger.debug("handleRequest()");
-		try
-		{
-			// insure that incoming data is parsed as UTF-8
-			request.setCharacterEncoding("UTF-8");
-		}
-		catch (UnsupportedEncodingException e)
-		{
-			throw new ServletException("Can't set incoming encoding to UTF-8");
-		}
-    	        
+
         ctx.put("term", "");
         ctx.put("hits", new Integer(0));
         ctx.put("searchResults", new TreeMap());          



Mime
View raw message