Doctor/Security: fix telegram numeric ID + symlink config permission warnings (#19844)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: e42bf1e48d
Co-authored-by: joshp123 <1497361+joshp123@users.noreply.github.com>
Co-authored-by: joshp123 <1497361+joshp123@users.noreply.github.com>
Reviewed-by: @joshp123
This commit is contained in:
the sun gif man
2026-02-18 00:09:51 -08:00
committed by GitHub
parent 7ea7b7e7af
commit 114736ed1a
8 changed files with 82 additions and 11 deletions

View File

@@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import { isNumericTelegramUserId, normalizeTelegramAllowFromEntry } from "./allow-from.js";
describe("telegram allow-from helpers", () => {
it("normalizes tg/telegram prefixes", () => {
expect(normalizeTelegramAllowFromEntry(" TG:123 ")).toBe("123");
expect(normalizeTelegramAllowFromEntry("telegram:@someone")).toBe("@someone");
});
it("accepts signed numeric IDs", () => {
expect(isNumericTelegramUserId("123456789")).toBe(true);
expect(isNumericTelegramUserId("-1001234567890")).toBe(true);
expect(isNumericTelegramUserId("@someone")).toBe(false);
expect(isNumericTelegramUserId("12 34")).toBe(false);
});
});

View File

@@ -7,5 +7,5 @@ export function normalizeTelegramAllowFromEntry(raw: unknown): string {
}
export function isNumericTelegramUserId(raw: string): boolean {
return /^\d+$/.test(raw);
return /^-?\d+$/.test(raw);
}