Skip to content

Commit

Permalink
strip non printable chars from document's history comment
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jul 12, 2023
1 parent b6c8977 commit 1e75536
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e75536

Please sign in to comment.