]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java
Trim zero bytes from profile fields
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / util / ProfileUtils.java
index 213f516c2ca564e963210af7631c2cbb01f14911..f6f76c2c5739cf2d051b124bc9e37a9707eb0bfa 100644 (file)
@@ -18,8 +18,8 @@ public class ProfileUtils {
         var profileCipher = new ProfileCipher(profileKey);
         try {
             var name = decrypt(encryptedProfile.getName(), profileCipher);
-            var about = decrypt(encryptedProfile.getAbout(), profileCipher);
-            var aboutEmoji = decrypt(encryptedProfile.getAboutEmoji(), profileCipher);
+            var about = trimZeros(decrypt(encryptedProfile.getAbout(), profileCipher));
+            var aboutEmoji = trimZeros(decrypt(encryptedProfile.getAboutEmoji(), profileCipher));
 
             final var nameParts = splitName(name);
             return new Profile(System.currentTimeMillis(),
@@ -95,4 +95,13 @@ public class ProfileUtils {
                 return new Pair<>(parts[0], parts[1]);
         }
     }
+
+    static String trimZeros(String str) {
+        if (str == null) {
+            return null;
+        }
+
+        int pos = str.indexOf(0);
+        return pos == -1 ? str : str.substring(0, pos);
+    }
 }