mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
fixup
This commit is contained in:
@@ -82,14 +82,11 @@ describe("UrlParams", () => {
|
|||||||
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
|
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
|
||||||
).toBe(ROOM_ID);
|
).toBe(ROOM_ID);
|
||||||
});
|
});
|
||||||
it("(roomId with unprintable chatacters)", () => {
|
it("handles params with unprintable characters", () => {
|
||||||
const invisibleChar = "\u2066";
|
const invisibleChar = "\u2066";
|
||||||
expect(
|
expect(
|
||||||
getRoomIdentifierFromUrl(
|
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}${invisibleChar}`, "")
|
||||||
"",
|
.roomId,
|
||||||
`?roomId=${invisibleChar}${ROOM_ID}${invisibleChar}`,
|
|
||||||
"",
|
|
||||||
).roomId,
|
|
||||||
).toBe(ROOM_ID);
|
).toBe(ROOM_ID);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -220,6 +220,8 @@ class ParamParser {
|
|||||||
private queryParams: URLSearchParams;
|
private queryParams: URLSearchParams;
|
||||||
|
|
||||||
public constructor(search: string, hash: string) {
|
public constructor(search: string, hash: string) {
|
||||||
|
// Replace any non-printable characters that another client may have inserted.
|
||||||
|
search = search.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
|
||||||
this.queryParams = new URLSearchParams(search);
|
this.queryParams = new URLSearchParams(search);
|
||||||
|
|
||||||
const fragmentQueryStart = hash.indexOf("?");
|
const fragmentQueryStart = hash.indexOf("?");
|
||||||
@@ -258,6 +260,8 @@ export const getUrlParams = (
|
|||||||
search = window.location.search,
|
search = window.location.search,
|
||||||
hash = window.location.hash,
|
hash = window.location.hash,
|
||||||
): UrlParams => {
|
): UrlParams => {
|
||||||
|
// Replace any non-printable characters that another client may have inserted.
|
||||||
|
search = search.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
|
||||||
const parser = new ParamParser(search, hash);
|
const parser = new ParamParser(search, hash);
|
||||||
|
|
||||||
const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
|
const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
|
||||||
@@ -387,14 +391,10 @@ export function getRoomIdentifierFromUrl(
|
|||||||
|
|
||||||
// Make sure roomId is valid
|
// Make sure roomId is valid
|
||||||
let roomId: string | null = parser.getParam("roomId");
|
let roomId: string | null = parser.getParam("roomId");
|
||||||
if (roomId !== null) {
|
if (!roomId?.startsWith("!")) {
|
||||||
// Replace any non-printable characters that another client may have inserted.
|
roomId = null;
|
||||||
roomId = roomId.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
|
} else if (!roomId.includes("")) {
|
||||||
if (!roomId.startsWith("!")) {
|
roomId = null;
|
||||||
roomId = null;
|
|
||||||
} else if (!roomId.includes("")) {
|
|
||||||
roomId = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user