Commit 38842fd5 authored by Guus der Kinderen's avatar Guus der Kinderen Committed by daryl herzmann

OF-394: Show proper error on invalid MUC room name. (#920)

When creating a new MUC room, using an invalid name (invalid JID) should not cause an ugly
stacktrace to be displayed.
parent 24c27352
......@@ -41,6 +41,8 @@
<% webManager.init(request, response, session, application, out); %>
<% // Get parameters
Map<String, String> errors = new HashMap<>();
boolean create = ParamUtils.getBooleanParameter(request,"create");
boolean save = ParamUtils.getBooleanParameter(request,"save");
boolean success = ParamUtils.getBooleanParameter(request,"success");
......@@ -50,12 +52,33 @@
String roomJIDStr = ParamUtils.getParameter(request,"roomJID");
JID roomJID = null;
if (roomName != null && mucName != null) {
roomJID = new JID(roomName, mucName, null);
try {
JID.nodeprep( roomName );
} catch ( IllegalArgumentException e ) {
errors.put("roomName","roomName");
}
try {
JID.domainprep( mucName );
} catch ( IllegalArgumentException e ) {
errors.put("mucName","mucName");
}
if ( errors.isEmpty() )
{
roomJID = new JID( roomName, mucName, null );
}
}
else if (roomJIDStr != null) {
roomJID = new JID(roomJIDStr);
roomName = roomJID.getNode();
mucName = roomJID.getDomain();
try {
roomJID = new JID( roomJIDStr );
} catch ( IllegalArgumentException e ) {
errors.put( "roomJID", "roomJID" );
}
if ( roomJID != null )
{
roomName = roomJID.getNode();
mucName = roomJID.getDomain();
}
}
String naturalName = ParamUtils.getParameter(request,"roomconfig_roomname");
String description = ParamUtils.getParameter(request,"roomconfig_roomdesc");
......@@ -110,7 +133,6 @@
}
// Handle an save
Map<String, String> errors = new HashMap<String, String>();
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
......
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