From 3f24fc83fd1ad136b43f862fc229f9410dfafb6a Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:11:26 +0100 Subject: [PATCH] fix: don't reject entire imports if player has battle scores --- .../lib/score-import/import-types/common/api-cg/parsers.ts | 6 +++++- .../import-types/common/api-cg/popn/converter.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/lib/score-import/import-types/common/api-cg/parsers.ts b/server/src/lib/score-import/import-types/common/api-cg/parsers.ts index 5849991cb..ca5c00e50 100644 --- a/server/src/lib/score-import/import-types/common/api-cg/parsers.ts +++ b/server/src/lib/score-import/import-types/common/api-cg/parsers.ts @@ -77,7 +77,11 @@ const PR_CG_POPN = { difficulty: p.isPositiveInteger, version: p.isPositiveInteger, clearFlag: p.isPositiveInteger, - score: p.isBoundedInteger(0, 100_000), + + // edge case. Score can go above 100k in battle mode. + // although we don't support battle mode, + // we cannot reject this in the parser - as it will cancel the entire import. + score: p.isPositiveInteger, coolCount: p.isPositiveInteger, greatCount: p.isPositiveInteger, diff --git a/server/src/lib/score-import/import-types/common/api-cg/popn/converter.ts b/server/src/lib/score-import/import-types/common/api-cg/popn/converter.ts index 0480ea22c..7626eb353 100644 --- a/server/src/lib/score-import/import-types/common/api-cg/popn/converter.ts +++ b/server/src/lib/score-import/import-types/common/api-cg/popn/converter.ts @@ -23,6 +23,10 @@ export const ConverterAPICGPopn: ConverterFunction = asy const difficulty = ConvertDifficulty(data.difficulty); const version = ConvertVersion(data.version); + if (data.score > 100_000) { + throw new InvalidScoreFailure(`Score is > 100_000 (got ${data.score})`); + } + const chart = await FindChartOnInGameIDVersion( "popn", data.internalId,