mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Prevent a crash caused by empty emoji
The crash happens because the serialization of recently used emoji uses ';' to separate the emojis. One of the ASCII emojis however has a ';' in the beginning. When this one is used by the user, it causes an empty string to be returned when deserializing. This commit prevents the crash by changing the separator to a tab. It uses a different settings string to store the emoji, so users will lose the list of recently used emoji when they update to this version. PS. That wasn't my idea ;)
This commit is contained in:
@@ -104,8 +104,9 @@ public class EmojiPageView extends FrameLayout {
|
||||
emojiSize + 2 * pad));
|
||||
view = emojiView;
|
||||
}
|
||||
String emoji = model.getEmoji()[position];
|
||||
view.setEmoji(emoji);
|
||||
|
||||
view.setEmoji(model.getEmoji()[position]);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class RecentEmojiPageModel implements EmojiPageModel {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(RecentEmojiPageModel.class.getName());
|
||||
|
||||
private static final String EMOJI_LRU_PREFERENCE = "pref_emoji_recent";
|
||||
private static final String EMOJI_LRU_PREFERENCE = "pref_emoji_recent2";
|
||||
private static final int EMOJI_LRU_SIZE = 50;
|
||||
|
||||
private final LinkedHashSet<String> recentlyUsed; // UI thread
|
||||
@@ -98,12 +98,12 @@ public class RecentEmojiPageModel implements EmojiPageModel {
|
||||
}
|
||||
|
||||
private String serialize(LinkedHashSet<String> emojis) {
|
||||
return StringUtils.join(emojis, ";");
|
||||
return StringUtils.join(emojis, "\t");
|
||||
}
|
||||
|
||||
private LinkedHashSet<String> deserialize(@Nullable String serialized) {
|
||||
if (serialized == null) return new LinkedHashSet<>();
|
||||
String[] list = serialized.split(";");
|
||||
String[] list = serialized.split("\t");
|
||||
LinkedHashSet<String> result = new LinkedHashSet<>(list.length);
|
||||
Collections.addAll(result, list);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user