mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 12:37:58 +01:00
Use Locale.US when doing String operations
on machine readable output. The default locale may not provide the wanted mapping. See also http://developer.android.com/reference/java/util/Locale.html#default_locale SMACK-467
This commit is contained in:
parent
94adaf8e50
commit
d8a5610d7b
24 changed files with 67 additions and 39 deletions
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import java.io.PipedReader;
|
||||
import java.io.PipedWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -247,7 +248,7 @@ public class BOSHConnection extends XMPPConnection {
|
|||
throw new AlreadyLoggedInException();
|
||||
}
|
||||
// Do partial version of nameprep on the username.
|
||||
username = username.toLowerCase().trim();
|
||||
username = username.toLowerCase(Locale.US).trim();
|
||||
|
||||
String response;
|
||||
if (saslAuthentication.hasNonAnonymousAuthentication()) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
@ -422,7 +423,7 @@ public class Roster {
|
|||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return entries.get(user.toLowerCase());
|
||||
return entries.get(user.toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -633,7 +634,7 @@ public class Roster {
|
|||
if (!contains(user)) {
|
||||
key = StringUtils.parseBareAddress(user);
|
||||
}
|
||||
return key.toLowerCase();
|
||||
return key.toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
|
@ -122,7 +123,7 @@ public class RosterGroup {
|
|||
// Roster entries never include a resource so remove the resource
|
||||
// if it's a part of the XMPP address.
|
||||
user = StringUtils.parseBareAddress(user);
|
||||
String userLowerCase = user.toLowerCase();
|
||||
String userLowerCase = user.toLowerCase(Locale.US);
|
||||
synchronized (entries) {
|
||||
for (RosterEntry entry : entries) {
|
||||
if (entry.getUser().equals(userLowerCase)) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -86,9 +87,9 @@ public class IQReplyFilter implements PacketFilter {
|
|||
// in an early stage, i.e. when performing the SASL auth.
|
||||
local = null;
|
||||
} else {
|
||||
local = conn.getUser().toLowerCase();
|
||||
local = conn.getUser().toLowerCase(Locale.US);
|
||||
}
|
||||
server = conn.getServiceName().toLowerCase();
|
||||
server = conn.getServiceName().toLowerCase(Locale.US);
|
||||
packetId = iqPacket.getPacketID();
|
||||
|
||||
PacketFilter iqFilter = new OrFilter(new IQTypeFilter(IQ.Type.ERROR), new IQTypeFilter(IQ.Type.RESULT));
|
||||
|
@ -101,7 +102,7 @@ public class IQReplyFilter implements PacketFilter {
|
|||
fromFilter.addFilter(FromMatchesFilter.createBare(local));
|
||||
fromFilter.addFilter(FromMatchesFilter.createFull(server));
|
||||
}
|
||||
else if (local != null && to.toLowerCase().equals(StringUtils.parseBareAddress(local))) {
|
||||
else if (local != null && to.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(local))) {
|
||||
fromFilter.addFilter(FromMatchesFilter.createFull(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
|
@ -202,7 +204,7 @@ public abstract class IQ extends Packet {
|
|||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
type = type.toLowerCase();
|
||||
type = type.toLowerCase(Locale.US);
|
||||
if (GET.toString().equals(type)) {
|
||||
return GET;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class Packet {
|
|||
private static final Logger LOGGER = Logger.getLogger(Packet.class.getName());
|
||||
|
||||
protected static final String DEFAULT_LANGUAGE =
|
||||
java.util.Locale.getDefault().getLanguage().toLowerCase();
|
||||
java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US);
|
||||
|
||||
private static String DEFAULT_XML_NS = null;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class RosterPacket extends IQ {
|
|||
* @param name the user's name.
|
||||
*/
|
||||
public Item(String user, String name) {
|
||||
this.user = user.toLowerCase();
|
||||
this.user = user.toLowerCase(Locale.US);
|
||||
this.name = name;
|
||||
itemType = null;
|
||||
itemStatus = null;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -157,7 +158,7 @@ public class XMPPError {
|
|||
buf.append("<error");
|
||||
if (type != null) {
|
||||
buf.append(" type=\"");
|
||||
buf.append(type.name().toLowerCase());
|
||||
buf.append(type.name().toLowerCase(Locale.US));
|
||||
buf.append("\"");
|
||||
}
|
||||
buf.append(">");
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -744,11 +745,11 @@ public class PacketParserUtils {
|
|||
XMPPError.Type errorType = XMPPError.Type.CANCEL;
|
||||
try {
|
||||
if (type != null) {
|
||||
errorType = XMPPError.Type.valueOf(type.toUpperCase());
|
||||
errorType = XMPPError.Type.valueOf(type.toUpperCase(Locale.US));
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException iae) {
|
||||
LOGGER.log(Level.SEVERE, "Could not find error type for " + type.toUpperCase(), iae);
|
||||
LOGGER.log(Level.SEVERE, "Could not find error type for " + type.toUpperCase(Locale.US), iae);
|
||||
}
|
||||
return new XMPPError(errorType, condition, message, extensions);
|
||||
}
|
||||
|
|
|
@ -802,7 +802,7 @@ public class PacketParserUtilsTest {
|
|||
Locale[] availableLocales = Locale.getAvailableLocales();
|
||||
for (int i = 0; i < availableLocales.length; i++) {
|
||||
if (availableLocales[i] != Locale.getDefault()) {
|
||||
otherLanguage = availableLocales[i].getLanguage().toLowerCase();
|
||||
otherLanguage = availableLocales[i].getLanguage().toLowerCase(Locale.US);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
|
@ -120,7 +122,7 @@ public class Open extends IQ {
|
|||
buf.append(sessionID);
|
||||
buf.append("\" ");
|
||||
buf.append("stanza=\"");
|
||||
buf.append(stanza.toString().toLowerCase());
|
||||
buf.append(stanza.toString().toLowerCase(Locale.US));
|
||||
buf.append("\"");
|
||||
buf.append("/>");
|
||||
return buf.toString();
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
|
@ -39,7 +41,7 @@ public class OpenIQProvider implements IQProvider {
|
|||
stanza = StanzaType.IQ;
|
||||
}
|
||||
else {
|
||||
stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
|
||||
stanza = StanzaType.valueOf(stanzaValue.toUpperCase(Locale.US));
|
||||
}
|
||||
|
||||
return new Open(sessionID, blockSize, stanza);
|
||||
|
|
|
@ -54,6 +54,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.SortedSet;
|
||||
|
@ -278,7 +279,7 @@ public class EntityCapsManager extends Manager {
|
|||
CapsExtension ext = (CapsExtension) packet.getExtension(EntityCapsManager.ELEMENT,
|
||||
EntityCapsManager.NAMESPACE);
|
||||
|
||||
String hash = ext.getHash().toLowerCase();
|
||||
String hash = ext.getHash().toLowerCase(Locale.US);
|
||||
if (!SUPPORTED_HASHES.containsKey(hash))
|
||||
return;
|
||||
|
||||
|
@ -560,7 +561,7 @@ public class EntityCapsManager extends Manager {
|
|||
* supported
|
||||
*/
|
||||
protected static String generateVerificationString(DiscoverInfo discoverInfo, String hash) {
|
||||
MessageDigest md = SUPPORTED_HASHES.get(hash.toLowerCase());
|
||||
MessageDigest md = SUPPORTED_HASHES.get(hash.toLowerCase(Locale.US));
|
||||
if (md == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -169,7 +170,7 @@ public class MultiUserChat {
|
|||
*/
|
||||
public MultiUserChat(XMPPConnection connection, String room) {
|
||||
this.connection = connection;
|
||||
this.room = room.toLowerCase();
|
||||
this.room = room.toLowerCase(Locale.US);
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -150,21 +151,21 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
|
|||
if (from == null) {
|
||||
return false;
|
||||
}
|
||||
return roomAddressTable.containsKey(StringUtils.parseBareAddress(from).toLowerCase());
|
||||
return roomAddressTable.containsKey(StringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
public void addRoom(String address) {
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
roomAddressTable.put(address.toLowerCase(), address);
|
||||
roomAddressTable.put(address.toLowerCase(Locale.US), address);
|
||||
}
|
||||
|
||||
public void removeRoom(String address) {
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
roomAddressTable.remove(address.toLowerCase());
|
||||
roomAddressTable.remove(address.toLowerCase(Locale.US));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +192,7 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
|
|||
}
|
||||
|
||||
PacketMultiplexListener listener =
|
||||
roomListenersByAddress.get(StringUtils.parseBareAddress(from).toLowerCase());
|
||||
roomListenersByAddress.get(StringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
|
||||
if (listener != null) {
|
||||
listener.processPacket(p);
|
||||
|
@ -202,14 +203,14 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
|
|||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
roomListenersByAddress.put(address.toLowerCase(), listener);
|
||||
roomListenersByAddress.put(address.toLowerCase(Locale.US), listener);
|
||||
}
|
||||
|
||||
public void removeRoom(String address) {
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
roomListenersByAddress.remove(address.toLowerCase());
|
||||
roomListenersByAddress.remove(address.toLowerCase(Locale.US));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
||||
/**
|
||||
|
@ -48,6 +50,6 @@ public enum FormNodeType
|
|||
{
|
||||
return CONFIGURE_OWNER;
|
||||
}
|
||||
return valueOf(elem.toUpperCase());
|
||||
return valueOf(elem.toUpperCase(Locale.US));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
||||
/**
|
||||
|
@ -75,9 +77,9 @@ public enum PubSubElementType
|
|||
|
||||
if (fragment != null)
|
||||
{
|
||||
return valueOf((elemName + '_' + fragment).toUpperCase());
|
||||
return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US));
|
||||
}
|
||||
return valueOf(elemName.toUpperCase().replace('-', '_'));
|
||||
return valueOf(elemName.toUpperCase(Locale.US).replace('-', '_'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.packet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Defines all the valid namespaces that are used with the {@link PubSub} packet
|
||||
* as defined by the specification.
|
||||
|
@ -58,7 +60,7 @@ public enum PubSubNamespace
|
|||
if (index != -1)
|
||||
{
|
||||
String suffix = ns.substring(ns.lastIndexOf('#')+1);
|
||||
return valueOf(suffix.toUpperCase());
|
||||
return valueOf(suffix.toUpperCase(Locale.US));
|
||||
}
|
||||
else
|
||||
return BASIC;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.media;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Content info. Content info messages are complementary messages that can be
|
||||
* transmitted for informing of events like "busy", "ringtone", etc.
|
||||
|
@ -55,7 +57,7 @@ public abstract class ContentInfo {
|
|||
* Returns the MediaInfo constant associated with the String value.
|
||||
*/
|
||||
public static ContentInfo fromString(String value) {
|
||||
value = value.toLowerCase();
|
||||
value = value.toLowerCase(Locale.US);
|
||||
if (value.equals("busy")) {
|
||||
return BUSY;
|
||||
} else if (value.equals("hold")) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.net.UnknownHostException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
@ -468,7 +469,7 @@ public abstract class TransportCandidate {
|
|||
if (value == null) {
|
||||
return UDP;
|
||||
}
|
||||
value = value.toLowerCase();
|
||||
value = value.toLowerCase(Locale.US);
|
||||
if (value.equals("udp")) {
|
||||
return UDP;
|
||||
} else if (value.equals("tcp")) {
|
||||
|
@ -552,7 +553,7 @@ public abstract class TransportCandidate {
|
|||
if (value == null) {
|
||||
return MYRTPVOICE;
|
||||
}
|
||||
value = value.toLowerCase();
|
||||
value = value.toLowerCase(Locale.US);
|
||||
if (value.equals("myrtpvoice")) {
|
||||
return MYRTPVOICE;
|
||||
} else if (value.equals("tcp")) {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smackx.jingle.packet;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.jingle.media.ContentInfo;
|
||||
|
@ -87,7 +89,7 @@ public class JingleError implements PacketExtension {
|
|||
*/
|
||||
public static JingleError fromString(String value) {
|
||||
if (value != null) {
|
||||
value = value.toLowerCase();
|
||||
value = value.toLowerCase(Locale.US);
|
||||
if (value.equals("out-of-order")) {
|
||||
return OUT_OF_ORDER;
|
||||
} else if (value.equals("unknown-session")) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -180,7 +181,7 @@ public class AgentRoster {
|
|||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase().equals(jid.toLowerCase())) {
|
||||
if (entry.toLowerCase(Locale.US).equals(jid.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ public class AgentRoster {
|
|||
private String getPresenceMapKey(String user) {
|
||||
String key = user;
|
||||
if (!contains(user)) {
|
||||
key = StringUtils.parseBareAddress(user).toLowerCase();
|
||||
key = StringUtils.parseBareAddress(user).toLowerCase(Locale.US);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ public class AgentRoster {
|
|||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
if (entry.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +344,7 @@ public class AgentRoster {
|
|||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = (String)i.next();
|
||||
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
if (entry.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class WorkgroupQueue {
|
|||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
type = type.toLowerCase();
|
||||
type = type.toLowerCase(Locale.US);
|
||||
if (OPEN.toString().equals(type)) {
|
||||
return OPEN;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Creates a socket connection to a XMPP server. This is the default connection
|
||||
|
@ -223,7 +224,7 @@ public class TCPConnection extends XMPPConnection {
|
|||
throw new AlreadyLoggedInException();
|
||||
}
|
||||
// Do partial version of nameprep on the username.
|
||||
username = username.toLowerCase().trim();
|
||||
username = username.toLowerCase(Locale.US).trim();
|
||||
|
||||
String response;
|
||||
if (saslAuthentication.hasNonAnonymousAuthentication()) {
|
||||
|
|
Loading…
Reference in a new issue