You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2022/07/25 07:21:07 UTC

[ofbiz-framework] branch release22.01 updated: Improved: Strip data to maximum column length for initialRequest and (#526)

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release22.01
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release22.01 by this push:
     new 5a326dfb9a Improved: Strip data to maximum column length for initialRequest and (#526)
5a326dfb9a is described below

commit 5a326dfb9a8eec854e1288a434413cbd0582cd3c
Author: georg1312 <10...@users.noreply.github.com>
AuthorDate: Mon Jul 25 09:14:08 2022 +0200

    Improved: Strip data to maximum column length for initialRequest and (#526)
    
    initialReferrer (OFBIZ-12672)
    
    Analogous to the existing limitation of the "initialUserAgent" to 250
    characters, installation of a limitation of 2000 characters for
    initialRequest and initialReferrer, so as not to exit with
    "MysqlDataTruncation: Data truncation: Data too long for column
    'INITIAL_REFERRER' at row 1" in the case of very long requests.
---
 .../main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
index 5df4bfd6ce..4109ade770 100644
--- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
+++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
@@ -150,8 +150,14 @@ public class VisitHandler {
                             visit.set("fromDate", new Timestamp(session.getCreationTime()));
 
                             visit.set("initialLocale", initialLocale);
-                            visit.set("initialRequest", initialRequest);
-                            visit.set("initialReferrer", initialReferrer);
+                            if (initialRequest != null) {
+                                visit.set("initialRequest", initialRequest.length() > 2000 ? initialRequest.substring(0, 1999)
+                                        : initialRequest);
+                            }
+                            if (initialReferrer != null) {
+                                visit.set("initialReferrer", initialReferrer.length() > 2000 ? initialReferrer.substring(0, 1999)
+                                        : initialReferrer);
+                            }
                             if (initialUserAgent != null) {
                                 visit.set("initialUserAgent", initialUserAgent.length() > 250 ? initialUserAgent.substring(0, 250)
                                         : initialUserAgent);