Skip to content

Commit

Permalink
Strip non printable chars in document history's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jul 12, 2023
1 parent 0103814 commit 835754a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ public void markHistoriesAsRead(String event, long userId) {
public void store(DocumentHistory history) throws PersistenceException {
// Write only if the history is enabled
if (RunLevel.current().aspectEnabled(History.ASPECT)) {
if (history.getComment() != null && history.getComment().length() > 4000)
if (history.getComment() != null) {
// remove non printable chars
history.setComment(history.getComment().replaceAll("\\p{C}", ""));

// trim to 4000 chars
history.setComment(StringUtils.abbreviate(history.getComment(), 4000));
}
super.store(history);
EventCollector.get().newEvent(history);
}
Expand Down

0 comments on commit 835754a

Please sign in to comment.