fix some types of input from not rendering correctly

dbus-notify
Zlatin Balevsky 2022-06-10 17:40:35 +01:00
parent a9bc2ec43a
commit 0fe9f6b391
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 24 additions and 1 deletions

View File

@ -18,6 +18,22 @@ import net.i2p.util.ConcurrentHashSet;
public class DataUtil {
/** The 32 valid Base32 values. */
private final static char[] ALPHABET = {'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z',
'2', '3', '4', '5', '6', '7'};
public static boolean validBase32(char c) {
for (int i = 0; i < ALPHABET.length; i++) {
if (ALPHABET[i] == c)
return true;
}
return false;
}
private final static int MAX_SHORT = (0x1 << 16) - 1;
static void writeUnsignedShort(int value, OutputStream os) throws IOException {

View File

@ -1,6 +1,7 @@
package com.muwire.gui.chat
import com.muwire.core.Constants
import com.muwire.core.util.DataUtil
import com.muwire.gui.UISettings
import com.muwire.gui.contacts.POPLabel
import com.muwire.gui.profile.PersonaOrProfile
@ -23,7 +24,7 @@ class ChatEntry extends JTextPane {
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM hh:mm:ss")
private static final char AT = "@".toCharacter()
private final UISettings settings
private final Function<String, PersonaOrProfile> function
@ -132,6 +133,12 @@ class ChatEntry extends JTextPane {
@Override
ParsingState consume(char c) {
if (!DataUtil.validBase32(c)) {
consumed = true
String payload = "${currentName}${stringBuilder.toString()}"
tokens << new TextChatToken(payload)
return new TextParsingState()
}
if (stringBuilder.length() == maxSize) {
consumed = true
String readableName = "${currentName}${stringBuilder.toString()}"