Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace emojis characters by images in the metadata viewer (#1877) #1878

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 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,12 @@ 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);
return new String(outBytes, StandardCharsets.UTF_8);
}

public static byte[] replaceByImages(byte[] inBytes) {
synchronized (init) {
if (!init.get()) {
Expand Down Expand Up @@ -126,7 +132,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