mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: sanitize string for custom ConnectionId
parent
425fe0983c
commit
eddf86f430
|
@ -342,11 +342,12 @@ public abstract class SessionManager {
|
||||||
try {
|
try {
|
||||||
JsonObject serverMetadataJson = JsonParser.parseString(serverMetadata).getAsJsonObject();
|
JsonObject serverMetadataJson = JsonParser.parseString(serverMetadata).getAsJsonObject();
|
||||||
String customConnectionId = serverMetadataJson.get("openviduCustomConnectionId").getAsString();
|
String customConnectionId = serverMetadataJson.get("openviduCustomConnectionId").getAsString();
|
||||||
|
customConnectionId = customConnectionId.replaceAll("\\W", ""); // Remove all non-word characters: [^A-Za-z0-9_]
|
||||||
customConnectionId = customConnectionId.replaceAll(IdentifierPrefixes.PARTICIPANT_PUBLIC_ID, "");
|
customConnectionId = customConnectionId.replaceAll(IdentifierPrefixes.PARTICIPANT_PUBLIC_ID, "");
|
||||||
tokenObj.setConnectionId(IdentifierPrefixes.PARTICIPANT_PUBLIC_ID + customConnectionId);
|
tokenObj.setConnectionId(IdentifierPrefixes.PARTICIPANT_PUBLIC_ID + customConnectionId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug(
|
log.debug(
|
||||||
"Tried to parse server metadata as JSON after encountering \"openviduCustomConnectionId\" string but failed with {}: {}",
|
"Tried to parse server metadata as JSON after encountering \"openviduCustomConnectionId\" string, but failed with {}: {}",
|
||||||
e.getClass().getCanonicalName(), e.getMessage());
|
e.getClass().getCanonicalName(), e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue