openvidu-server: check param customSessionId (alphanumeric string)

pull/391/head
pabloFuente 2020-02-04 11:11:15 +01:00
parent 189c6264c2
commit c2da80429e
2 changed files with 11 additions and 1 deletions

View File

@ -140,6 +140,11 @@ public class SessionRestController {
builder = builder.mediaMode(MediaMode.ROUTED); builder = builder.mediaMode(MediaMode.ROUTED);
} }
if (customSessionId != null && !customSessionId.isEmpty()) { if (customSessionId != null && !customSessionId.isEmpty()) {
if (!sessionManager.formatChecker.isValidCustomSessionId(customSessionId)) {
return this.generateErrorResponse(
"Parameter \"customSessionId\" is wrong. Must be an alphanumeric string",
"/api/sessions", HttpStatus.BAD_REQUEST);
}
builder = builder.customSessionId(customSessionId); builder = builder.customSessionId(customSessionId);
} }
builder = builder.defaultCustomLayout((defaultCustomLayout != null) ? defaultCustomLayout : ""); builder = builder.defaultCustomLayout((defaultCustomLayout != null) ? defaultCustomLayout : "");

View File

@ -24,9 +24,14 @@ public class FormatChecker {
// with 0 and 3 digits long or 4 digits long if they start with 1 // with 0 and 3 digits long or 4 digits long if they start with 1
return stringResolution.matches("^(?!(0))(([0-9]{3})|1([0-9]{3}))x(?!0)(([0-9]{3})|1([0-9]{3}))$"); return stringResolution.matches("^(?!(0))(([0-9]{3})|1([0-9]{3}))x(?!0)(([0-9]{3})|1([0-9]{3}))$");
} }
public boolean isServerMetadataFormatCorrect(String metadata) { public boolean isServerMetadataFormatCorrect(String metadata) {
return true; return true;
} }
public boolean isValidCustomSessionId(String customSessionId) {
// Alphanumeric string
return customSessionId.matches("[a-zA-Z0-9]+");
}
} }