mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02: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
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue