mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:20:43 +00:00
bugfix: use FlagSchema to validate flag
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Cosmetics } from "../core/CosmeticSchemas";
|
||||
import { decodePatternData } from "../core/PatternDecoder";
|
||||
import {
|
||||
FlagSchema,
|
||||
PlayerColor,
|
||||
PlayerCosmeticRefs,
|
||||
PlayerCosmetics,
|
||||
@@ -42,10 +43,14 @@ export class PrivilegeCheckerImpl implements PrivilegeChecker {
|
||||
}
|
||||
}
|
||||
if (refs.flag) {
|
||||
cosmetics.flag = cosmetics.flag = refs.flag.replace(
|
||||
/[^a-z0-9-_ ()]/gi,
|
||||
"",
|
||||
);
|
||||
const result = FlagSchema.safeParse(refs.flag);
|
||||
if (!result.success) {
|
||||
return {
|
||||
type: "forbidden",
|
||||
reason: "invalid flag: " + result.error.message,
|
||||
};
|
||||
}
|
||||
cosmetics.flag = result.data;
|
||||
}
|
||||
|
||||
return { type: "allowed", cosmetics };
|
||||
|
||||
Reference in New Issue
Block a user