mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-19 06:20:25 +00:00
Trim roomId when parsing from URL
This commit is contained in:
@@ -82,6 +82,16 @@ describe("UrlParams", () => {
|
||||
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
|
||||
).toBe(ROOM_ID);
|
||||
});
|
||||
it("(roomId with unprintable chatacters)", () => {
|
||||
const invisibleChar = "";
|
||||
expect(
|
||||
getRoomIdentifierFromUrl(
|
||||
"",
|
||||
`?roomId=${invisibleChar}${ROOM_ID}${invisibleChar}`,
|
||||
"",
|
||||
).roomId,
|
||||
).toBe(ROOM_ID);
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores room alias", () => {
|
||||
|
||||
@@ -387,10 +387,14 @@ export function getRoomIdentifierFromUrl(
|
||||
|
||||
// Make sure roomId is valid
|
||||
let roomId: string | null = parser.getParam("roomId");
|
||||
if (!roomId?.startsWith("!")) {
|
||||
roomId = null;
|
||||
} else if (!roomId.includes("")) {
|
||||
roomId = null;
|
||||
if (roomId !== null) {
|
||||
// Replace any non-printable characters that another client may have inserted.
|
||||
roomId = roomId.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
|
||||
if (!roomId.startsWith("!")) {
|
||||
roomId = null;
|
||||
} else if (!roomId.includes("")) {
|
||||
roomId = null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user