From 1e755364a44f618f16d608a3018820b3dcc2ec5a Mon Sep 17 00:00:00 2001 From: car031 Date: Wed, 12 Jul 2023 11:13:27 +0200 Subject: [PATCH] strip non printable chars from document's history comment --- .../core/document/dao/HibernateDocumentHistoryDAO.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logicaldoc-core/src/main/java/com/logicaldoc/core/document/dao/HibernateDocumentHistoryDAO.java b/logicaldoc-core/src/main/java/com/logicaldoc/core/document/dao/HibernateDocumentHistoryDAO.java index ad64aa618..900660213 100644 --- a/logicaldoc-core/src/main/java/com/logicaldoc/core/document/dao/HibernateDocumentHistoryDAO.java +++ b/logicaldoc-core/src/main/java/com/logicaldoc/core/document/dao/HibernateDocumentHistoryDAO.java @@ -127,11 +127,11 @@ public void store(DocumentHistory history) throws PersistenceException { // Write only if the history is enabled if (RunLevel.current().aspectEnabled(History.ASPECT)) { if (history.getComment() != null) { + // trim to 4000 chars + history.setComment(StringUtils.abbreviate(history.getComment(), 4000)); + // remove non printable chars, but maintanis the carriage returns and the tabs history.setComment(history.getComment().trim().replaceAll("[\\p{Cntrl}&&[^\\n]&&[^\\t]&&[^\\r]]", "")); - - // trim to 4000 chars - history.setComment(StringUtils.abbreviate(history.getComment(), 4000)); } super.store(history); EventCollector.get().newEvent(history);