Commit 97a137b7 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Be more permissive. Accept TO and FROM with empty strings.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8525 b35dd754-fafc-0310-a699-88a17e54d16e
parent c4f0c023
...@@ -69,17 +69,29 @@ public abstract class Packet { ...@@ -69,17 +69,29 @@ public abstract class Packet {
// Apply stringprep profiles to the "to" and "from" values. // Apply stringprep profiles to the "to" and "from" values.
String to = element.attributeValue("to"); String to = element.attributeValue("to");
if (to != null) { if (to != null) {
if (to.length() == 0) {
// Remove empty TO values
element.addAttribute("to", null);
}
else {
String[] parts = JID.getParts(to); String[] parts = JID.getParts(to);
toJID = new JID(parts[0], parts[1], parts[2], skipValidation); toJID = new JID(parts[0], parts[1], parts[2], skipValidation);
element.addAttribute("to", toJID.toString()); element.addAttribute("to", toJID.toString());
} }
}
String from = element.attributeValue("from"); String from = element.attributeValue("from");
if (from != null) { if (from != null) {
if (from.length() == 0) {
// Remove empty FROM values
element.addAttribute("from", null);
}
else {
String[] parts = JID.getParts(from); String[] parts = JID.getParts(from);
fromJID = new JID(parts[0], parts[1], parts[2], true); fromJID = new JID(parts[0], parts[1], parts[2], true);
element.addAttribute("from", fromJID.toString()); element.addAttribute("from", fromJID.toString());
} }
} }
}
/** /**
* Constructs a new Packet with no element data. This method is used by * Constructs a new Packet with no element data. This method is used by
...@@ -119,7 +131,7 @@ public abstract class Packet { ...@@ -119,7 +131,7 @@ public abstract class Packet {
*/ */
public JID getTo() { public JID getTo() {
String to = element.attributeValue("to"); String to = element.attributeValue("to");
if (to == null) { if (to == null || to.length() == 0) {
return null; return null;
} }
else { else {
...@@ -179,7 +191,7 @@ public abstract class Packet { ...@@ -179,7 +191,7 @@ public abstract class Packet {
*/ */
public JID getFrom() { public JID getFrom() {
String from = element.attributeValue("from"); String from = element.attributeValue("from");
if (from == null) { if (from == null || from.length() == 0) {
return null; return null;
} }
else { else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment