Skip to content

Commit

Permalink
Improve validation for gameId in createGame (#173)
Browse files Browse the repository at this point in the history
I realized we should be careful about validation here after combing through the existing 30 GB of data and finding some strange stuff. Nothing with gameId being invalid luckily, but people have definitely been reading the code for fun.
  • Loading branch information
ekzhang authored Dec 23, 2024
1 parent a97f8cb commit faeb411
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ export const createGame = functions.https.onCall(async (data, context) => {
if (
!(typeof gameId === "string") ||
gameId.length === 0 ||
gameId.length > MAX_GAME_ID_LENGTH
gameId.length > MAX_GAME_ID_LENGTH ||
!gameId.match(/^[a-zA-Z0-9_-]+$/)
) {
throw new functions.https.HttpsError(
"invalid-argument",
Expand Down

0 comments on commit faeb411

Please sign in to comment.