Skip to content

Commit 7160d8c

Browse files
authored
Merge pull request #2762 from sepinf-inc/#2761_FixPipeInBookmarks
Fix the rendering of bookmark names containing "|" character (#2761)
2 parents ef60593 + 42da864 commit 7160d8c

File tree

7 files changed

+16
-4
lines changed

7 files changed

+16
-4
lines changed

iped-app/src/main/java/iped/app/ui/BaseTableModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Object getValueAt(int row, int col) {
8888

8989
case 2:
9090
// Item Bookmarks
91-
return Util.concatStrings(App.get().appCase.getMultiBookmarks().getBookmarkList(App.get().appCase.getItemId(results.getLuceneIds()[row])));
91+
return Util.concatStrings(App.get().appCase.getMultiBookmarks().getBookmarkList(App.get().appCase.getItemId(results.getLuceneIds()[row])), true);
9292

9393
case 3:
9494
// Item Name

iped-app/src/main/java/iped/app/ui/GalleryCellEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public Component getTableCellEditorComponent(JTable table, Object value, boolean
101101
IMultiBookmarks bookmarks = App.get().appCase.getMultiBookmarks();
102102
check.setSelected(bookmarks.isChecked(cellValue.id));
103103
cLabel.setText(cellValue.name);
104-
String itemBookmarksStr = Util.concatStrings(bookmarks.getBookmarkList(cellValue.id));
104+
String itemBookmarksStr = Util.concatStrings(bookmarks.getBookmarkList(cellValue.id), true);
105105
cLabel.setToolTipText(itemBookmarksStr.isEmpty() ? null : itemBookmarksStr);
106106
cLabel.setIcon(BookmarkIcon.getIcon(bookmarks, itemBookmarksStr));
107107

iped-app/src/main/java/iped/app/ui/GalleryCellRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
104104
IMultiBookmarks bookmarks = App.get().appCase.getMultiBookmarks();
105105
check.setSelected(bookmarks.isChecked(cellValue.id));
106106
cLabel.setText(cellValue.name);
107-
String itemBookmarksStr = Util.concatStrings(bookmarks.getBookmarkList(cellValue.id));
107+
String itemBookmarksStr = Util.concatStrings(bookmarks.getBookmarkList(cellValue.id), true);
108108
cLabel.setToolTipText(itemBookmarksStr.isEmpty() ? null : itemBookmarksStr);
109109
cLabel.setIcon(BookmarkIcon.getIcon(bookmarks, itemBookmarksStr));
110110

iped-app/src/main/java/iped/app/ui/ResultTableModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public Object getValueAt(int row, int col) {
254254
}
255255

256256
if (field.equals(BOOKMARK_COL)) {
257-
return Util.concatStrings(app.appCase.getMultiBookmarks().getBookmarkList(app.ipedResult.getItem(row)));
257+
return Util.concatStrings(app.appCase.getMultiBookmarks().getBookmarkList(app.ipedResult.getItem(row)), true);
258258
}
259259

260260
if (item instanceof TimeItemId) {

iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkCellRenderer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public void setBookmarks(IMultiBookmarks bookmarks, String str) {
7474
} else {
7575
names = str.split(" \\| ");
7676
}
77+
for (int i = 0; i < names.length; i++) {
78+
names[i] = names[i].replace("||", "|");
79+
}
7780
lastStr = str;
7881
}
7982
if (colors == null || colors.length < names.length) {

iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkIcon.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ public static Icon getIcon(IMultiBookmarks bookmarks, String str) {
4949
return null;
5050
}
5151
if (str.indexOf(" | ") < 0) {
52+
str = str.replace("||", "|");
5253
return getIcon(bookmarks.getBookmarkColor(str));
5354
}
5455
// Multiple bookmarks
5556
String[] bookmarkNames = str.split(" \\| ");
5657
List<Color> l = new ArrayList<Color>(bookmarkNames.length);
5758
for (String name : bookmarkNames) {
59+
name = name.replace("||", "|");
5860
l.add(bookmarks.getBookmarkColor(name));
5961
}
6062
synchronized (iconPerColorList) {

iped-engine/src/main/java/iped/engine/util/Util.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,19 @@ public static Object readObject(String filePath) throws IOException, ClassNotFou
303303
}
304304

305305
public static String concatStrings(List<String> strings) {
306+
return concatStrings(strings, false);
307+
}
308+
309+
public static String concatStrings(List<String> strings, boolean escape) {
306310
if (strings == null) {
307311
return null;
308312
}
309313
if (strings.isEmpty()) {
310314
return "";
311315
}
316+
if (escape) {
317+
strings.replaceAll(s -> s.replace("|", "||"));
318+
}
312319
if (strings.size() == 1) {
313320
return strings.get(0);
314321
}

0 commit comments

Comments
 (0)