1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02:00

[xdata] Safe the raw character data of form field values

Related to SMACK-909.
This commit is contained in:
Florian Schmaus 2021-07-18 17:21:50 +02:00
parent 4643d07ef4
commit e626580f68
11 changed files with 178 additions and 56 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2020 Florian Schmaus
* Copyright 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -82,4 +82,11 @@ public class CollectionUtil {
}
return new HashSet<>(collection);
}
public static <T> List<T> emptyOrSingletonListFrom(T element) {
if (element == null) {
return Collections.emptyList();
}
return Collections.singletonList(element);
}
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2016-2020 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2016-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ package org.jivesoftware.smack.util;
import java.io.IOException;
import java.nio.CharBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
@ -605,4 +606,13 @@ public class StringUtils {
String[] lines = input.split(PORTABLE_NEWLINE_REGEX);
return Arrays.asList(lines);
}
public static List<String> toStrings(Collection<? extends CharSequence> charSequences) {
List<String> res = new ArrayList<>(charSequences.size());
for (CharSequence cs : charSequences) {
String string = cs.toString();
res.add(string);
}
return res;
}
}