chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1368384 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser: BrowserBindingUtils.java RepositoryService.java
Date Thu, 02 Aug 2012 08:44:02 GMT
Author: fmui
Date: Thu Aug  2 08:44:01 2012
New Revision: 1368384

URL: http://svn.apache.org/viewvc?rev=1368384&view=rev
Log:
Browser binding server: encode cookie value

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java?rev=1368384&r1=1368383&r2=1368384&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
Thu Aug  2 08:44:01 2012
@@ -22,8 +22,10 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.GregorianCalendar;
@@ -446,7 +448,13 @@ public class BrowserBindingUtils {
     public static void setCookie(HttpServletRequest request, HttpServletResponse response,
String repositoryId,
             String token, String value, int expiry) {
         if (token != null && token.length() > 0) {
-            Cookie transactionCookie = new Cookie(getCookieName(token), value);
+            String cookieValue = value;
+            try {
+                cookieValue = URLEncoder.encode(value, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+            }
+
+            Cookie transactionCookie = new Cookie(getCookieName(token), cookieValue);
             transactionCookie.setMaxAge(expiry);
             transactionCookie.setPath(request.getContextPath() + request.getServletPath()
+ "/" + repositoryId);
             response.addCookie(transactionCookie);
@@ -499,7 +507,7 @@ public class BrowserBindingUtils {
 
     public static void writeEmpty(HttpServletRequest request, HttpServletResponse response)
throws IOException {
         response.setContentLength(0);
-        response.setContentType("text/plain");
+        response.setContentType(HTML_MIME_TYPE);
         response.getWriter().flush();
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java?rev=1368384&r1=1368383&r2=1368384&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
Thu Aug  2 08:44:01 2012
@@ -29,6 +29,7 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
 
 import java.math.BigInteger;
+import java.net.URLDecoder;
 import java.util.List;
 
 import javax.servlet.http.Cookie;
@@ -107,7 +108,7 @@ public final class RepositoryService {
         if (request.getCookies() != null) {
             for (Cookie cookie : request.getCookies()) {
                 if (cookieName.equals(cookie.getName())) {
-                    cookieValue = cookie.getValue();
+                    cookieValue = URLDecoder.decode(cookie.getValue(), "UTF-8");
                     break;
                 }
             }



Mime
View raw message