fix caps hash calculation for empty form fields
This commit is contained in:
parent
fba7721cd5
commit
f6482c5a87
|
@ -17,6 +17,7 @@ import java.security.MessageDigest;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
|
@ -100,9 +101,9 @@ public class ServiceDiscoveryResult {
|
|||
|
||||
public ServiceDiscoveryResult(Cursor cursor) throws JSONException {
|
||||
this(
|
||||
cursor.getString(cursor.getColumnIndex(HASH)),
|
||||
Base64.decode(cursor.getString(cursor.getColumnIndex(VER)), Base64.DEFAULT),
|
||||
new JSONObject(cursor.getString(cursor.getColumnIndex(RESULT)))
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(HASH)),
|
||||
Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(VER)), Base64.DEFAULT),
|
||||
new JSONObject(cursor.getString(cursor.getColumnIndexOrThrow(RESULT)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -216,17 +217,18 @@ public class ServiceDiscoveryResult {
|
|||
s.append(clean(feature)).append("<");
|
||||
}
|
||||
|
||||
Collections.sort(forms, (lhs, rhs) -> lhs.getFormType().compareTo(rhs.getFormType()));
|
||||
Collections.sort(forms, Comparator.comparing(Data::getFormType));
|
||||
|
||||
for (Data form : forms) {
|
||||
s.append(clean(form.getFormType())).append("<");
|
||||
List<Field> fields = form.getFields();
|
||||
Collections.sort(fields, (lhs, rhs) -> Strings.nullToEmpty(lhs.getFieldName()).compareTo(Strings.nullToEmpty(rhs.getFieldName())));
|
||||
Collections.sort(
|
||||
fields, Comparator.comparing(lhs -> Strings.nullToEmpty(lhs.getFieldName())));
|
||||
for (Field field : fields) {
|
||||
s.append(Strings.nullToEmpty(field.getFieldName())).append("<");
|
||||
List<String> values = field.getValues();
|
||||
Collections.sort(values);
|
||||
for (String value : values) {
|
||||
final List<String> values = field.getValues();
|
||||
Collections.sort(values, Comparator.comparing(ServiceDiscoveryResult::blankNull));
|
||||
for (final String value : values) {
|
||||
s.append(blankNull(value)).append("<");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue