Protect against bad xmpp error types.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@5458 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2006-09-20 16:43:40 +00:00 committed by matt
parent 49a07980de
commit 48fac74878
1 changed files with 12 additions and 4 deletions

View File

@ -35,8 +35,8 @@ import java.util.Map;
/**
* Utility class that helps to parse packets. Any parsing packets method that must be shared
* between many clients must be placed in this utility class.
*
* between many clients must be placed in this utility class.
*
* @author Gaston Dombiak
*/
public class PacketParserUtils {
@ -337,8 +337,16 @@ public class PacketParserUtils {
}
}
}
return new XMPPError(Integer.parseInt(errorCode), XMPPError.Type
.valueOf(type.toUpperCase()), condition, message, extensions);
// Parse the error type.
XMPPError.Type errorType = XMPPError.Type.CANCEL;
try {
errorType = XMPPError.Type.valueOf(type.toUpperCase());
}
catch (IllegalArgumentException iae) {
// Print stack trace. We shouldn't be getting an illegal error type.
iae.printStackTrace();
}
return new XMPPError(Integer.parseInt(errorCode), errorType, condition, message, extensions);
}
/**