You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/12/10 11:01:12 UTC

svn commit: r1817692 - /ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java

Author: mbrohl
Date: Sun Dec 10 11:01:12 2017
New Revision: 1817692

URL: http://svn.apache.org/viewvc?rev=1817692&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package 
org.apache.ofbiz.marketing.tracking.
(OFBIZ-9823)

The patch was modified because the repeated conditional check in 
TrackingCodeEvents was simplified too much.

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java

Modified: ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java?rev=1817692&r1=1817691&r2=1817692&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java Sun Dec 10 11:01:12 2017
@@ -268,9 +268,17 @@ public class TrackingCodeEvents {
                 }
             }
 
-            if (visitorSiteId == null || (visitorSiteId != null && !visitorSiteId.equals(siteId) && siteId != null)) {
+            if (visitorSiteId == null || (siteId != null && !visitorSiteId.equals(siteId))) {
                 // if trackingCode.siteId is  not null  write a trackable cookie with name in the form: Ofbiz.TKCSiteId and timeout will be 60 * 60 * 24 * 365
-                Cookie siteIdCookie = new Cookie("Ofbiz.TKCD.SiteId", siteId);
+                String siteIdEnc;
+                try {
+                    siteIdEnc = URLEncoder.encode(siteId, "UTF-8");
+                }
+                catch (UnsupportedEncodingException e) {
+                    Debug.logWarning("There went something wrong while encoding for the cookie creation in TrackingCodeEvents.processTrackingCode", module);
+                    return "error";
+                }
+                Cookie siteIdCookie = new Cookie("Ofbiz.TKCD.SiteId", siteIdEnc);
                 siteIdCookie.setMaxAge(siteIdCookieAge);
                 siteIdCookie.setPath("/");
                 if (cookieDomain.length() > 0) siteIdCookie.setDomain(cookieDomain);