mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
fix(api): 🔒 Replace bad webfinger regex with good one
This commit is contained in:
parent
9ad0f88ff2
commit
4f070c9b65
3 changed files with 33 additions and 16 deletions
24
utils/api.ts
24
utils/api.ts
|
|
@ -11,7 +11,9 @@ import {
|
|||
createRegExp,
|
||||
digit,
|
||||
exactly,
|
||||
global,
|
||||
letter,
|
||||
maybe,
|
||||
oneOrMore,
|
||||
} from "magic-regexp";
|
||||
import { parse } from "qs";
|
||||
|
|
@ -64,6 +66,28 @@ export const emojiValidatorWithColons = createRegExp(
|
|||
[caseInsensitive],
|
||||
);
|
||||
|
||||
export const mentionValidator = createRegExp(
|
||||
exactly("@"),
|
||||
oneOrMore(anyOf(letter.lowercase, digit, charIn("-"))).groupedAs(
|
||||
"username",
|
||||
),
|
||||
maybe(
|
||||
exactly("@"),
|
||||
oneOrMore(anyOf(letter, digit, charIn("_-.:"))).groupedAs("domain"),
|
||||
),
|
||||
[global],
|
||||
);
|
||||
|
||||
export const webfingerMention = createRegExp(
|
||||
exactly("acct:"),
|
||||
oneOrMore(anyOf(letter, digit, charIn("-"))).groupedAs("username"),
|
||||
maybe(
|
||||
exactly("@"),
|
||||
oneOrMore(anyOf(letter, digit, charIn("_-.:"))).groupedAs("domain"),
|
||||
),
|
||||
[],
|
||||
);
|
||||
|
||||
export const handleZodError = (
|
||||
result:
|
||||
| { success: true; data?: object }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue