Compare commits

...

5 Commits

Author SHA1 Message Date
Will Hunt
38224895f3 Add a comment 2025-07-21 14:56:41 +01:00
Half-Shot
c4921f3855 limit to roomId 2025-07-21 12:22:49 +01:00
Half-Shot
99c4686689 fixup 2025-07-21 11:41:18 +01:00
Half-Shot
b722d7bdab fix char 2025-07-21 11:34:12 +01:00
Half-Shot
9b2223e383 Trim roomId when parsing from URL 2025-07-21 11:30:51 +01:00
2 changed files with 20 additions and 4 deletions

View File

@@ -82,6 +82,16 @@ describe("UrlParams", () => {
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
).toBe(ROOM_ID);
});
it("(roomId with unprintable characters)", () => {
const invisibleChar = "\u2066";
expect(
getRoomIdentifierFromUrl(
"",
`?roomId=${invisibleChar}${ROOM_ID}${invisibleChar}`,
"",
).roomId,
).toBe(ROOM_ID);
});
});
it("ignores room alias", () => {

View File

@@ -387,10 +387,16 @@ 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.
// For instance on iOS, some copied links end up with zero width characters on the end which get encoded into the URL.
// This isn't valid for a roomId, so we can freely strip the content.
roomId = roomId.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
if (!roomId.startsWith("!")) {
roomId = null;
} else if (!roomId.includes("")) {
roomId = null;
}
}
return {