mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Maximum name length is specified in UTF-8 bytes, not characters.
This commit is contained in:
@@ -3,6 +3,8 @@ package org.briarproject.api.messaging;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.GROUP_SALT_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_GROUP_NAME_LENGTH;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/** A group to which users may subscribe. */
|
||||
public class Group {
|
||||
|
||||
@@ -11,8 +13,13 @@ public class Group {
|
||||
private final byte[] salt;
|
||||
|
||||
public Group(GroupId id, String name, byte[] salt) {
|
||||
if(name.length() == 0 || name.length() > MAX_GROUP_NAME_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
if(name.length() == 0) throw new IllegalArgumentException();
|
||||
try {
|
||||
if(name.getBytes("UTF-8").length > MAX_GROUP_NAME_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(salt.length != GROUP_SALT_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
this.id = id;
|
||||
|
||||
Reference in New Issue
Block a user