Skip to content

Commit

Permalink
'#1877: Replace emojis characters by images in the metadata viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Sep 14, 2023
1 parent ef18f22 commit 22207b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion iped-utils/src/main/java/iped/utils/EmojiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public class EmojiUtil {
private static final Map<String, String> base64ImagesPerCode = new HashMap<String, String>();
private static final AtomicBoolean init = new AtomicBoolean();

public static String replaceByImages(String inStr) {
byte[] inBytes = inStr.getBytes(StandardCharsets.UTF_8);
byte[] outBytes = replaceByImages(inBytes);
String ret = new String(outBytes, StandardCharsets.UTF_8);
System.err.println(ret);
return ret;
}

public static byte[] replaceByImages(byte[] inBytes) {
synchronized (init) {
if (!init.get()) {
Expand Down Expand Up @@ -126,7 +134,7 @@ public static byte[] replaceByImages(byte[] inBytes) {
}
} else if (!bodyFound) {
out.println(s);
if (s.indexOf("<body>") >= 0) {
if (s.indexOf("<body") >= 0) {
bodyFound = true;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import iped.properties.BasicProps;
import iped.properties.ExtraProperties;
import iped.properties.MediaTypes;
import iped.utils.EmojiUtil;
import iped.utils.LocalizedFormat;
import iped.utils.SimpleHTMLEncoder;
import iped.utils.UiUtil;
Expand Down Expand Up @@ -229,7 +230,7 @@ private String generatePreview(IItemReader item, int tabIndex) {
sb.append("</body>"); //$NON-NLS-1$
sb.append("</html>"); //$NON-NLS-1$

return sb.toString();
return EmojiUtil.replaceByImages(sb.toString());
}

private void fillMetadata(StringBuilder sb, Metadata metadata) {
Expand Down

0 comments on commit 22207b1

Please sign in to comment.