mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: mandatory alphanumeric recording names
parent
5da1a82923
commit
ec03629c88
|
@ -144,7 +144,7 @@ public class SessionRestController {
|
||||||
if (customSessionId != null && !customSessionId.isEmpty()) {
|
if (customSessionId != null && !customSessionId.isEmpty()) {
|
||||||
if (!sessionManager.formatChecker.isValidCustomSessionId(customSessionId)) {
|
if (!sessionManager.formatChecker.isValidCustomSessionId(customSessionId)) {
|
||||||
return this.generateErrorResponse(
|
return this.generateErrorResponse(
|
||||||
"Parameter \"customSessionId\" is wrong. Must be an alphanumeric string",
|
"Parameter 'customSessionId' is wrong. Must be an alphanumeric string [a-zA-Z0-9_-]",
|
||||||
"/api/sessions", HttpStatus.BAD_REQUEST);
|
"/api/sessions", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
builder = builder.customSessionId(customSessionId);
|
builder = builder.customSessionId(customSessionId);
|
||||||
|
@ -485,28 +485,36 @@ public class SessionRestController {
|
||||||
HttpStatus.BAD_REQUEST);
|
HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name != null && !name.isEmpty()) {
|
||||||
|
if (!sessionManager.formatChecker.isValidRecordingName(name)) {
|
||||||
|
return this.generateErrorResponse(
|
||||||
|
"Parameter 'name' is wrong. Must be an alphanumeric string [a-zA-Z0-9_-]", "/api/sessions",
|
||||||
|
HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OutputMode finalOutputMode = OutputMode.COMPOSED;
|
OutputMode finalOutputMode = OutputMode.COMPOSED;
|
||||||
RecordingLayout recordingLayout = null;
|
RecordingLayout recordingLayout = null;
|
||||||
if (outputModeString != null && !outputModeString.isEmpty()) {
|
if (outputModeString != null && !outputModeString.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
finalOutputMode = OutputMode.valueOf(outputModeString);
|
finalOutputMode = OutputMode.valueOf(outputModeString);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start",
|
return this.generateErrorResponse("Type error in parameter 'outputMode'", "/api/recordings/start",
|
||||||
HttpStatus.BAD_REQUEST);
|
HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (RecordingUtils.IS_COMPOSED(finalOutputMode)) {
|
if (RecordingUtils.IS_COMPOSED(finalOutputMode)) {
|
||||||
if (resolution != null && !sessionManager.formatChecker.isAcceptableRecordingResolution(resolution)) {
|
if (resolution != null && !sessionManager.formatChecker.isAcceptableRecordingResolution(resolution)) {
|
||||||
return this.generateErrorResponse(
|
return this.generateErrorResponse(
|
||||||
"Wrong \"resolution\" parameter. Acceptable values from 100 to 1999 for both width and height",
|
"Wrong 'resolution' parameter. Acceptable values from 100 to 1999 for both width and height",
|
||||||
"/api/recordings/start", HttpStatus.UNPROCESSABLE_ENTITY);
|
"/api/recordings/start", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
if (recordingLayoutString != null && !recordingLayoutString.isEmpty()) {
|
if (recordingLayoutString != null && !recordingLayoutString.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
recordingLayout = RecordingLayout.valueOf(recordingLayoutString);
|
recordingLayout = RecordingLayout.valueOf(recordingLayoutString);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start",
|
return this.generateErrorResponse("Type error in parameter 'recordingLayout'",
|
||||||
HttpStatus.BAD_REQUEST);
|
"/api/recordings/start", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,15 @@ public class FormatChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidCustomSessionId(String customSessionId) {
|
public boolean isValidCustomSessionId(String customSessionId) {
|
||||||
// Alphanumeric string
|
return isValidAlphanumeric(customSessionId);
|
||||||
return customSessionId.matches("[a-zA-Z0-9_-]+");
|
}
|
||||||
|
|
||||||
|
public boolean isValidRecordingName(String recodingName) {
|
||||||
|
return isValidAlphanumeric(recodingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidAlphanumeric(String str) {
|
||||||
|
return str.matches("[a-zA-Z0-9_-]+");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue