From 9180d7a96544faef35ce56444051cbd1298fda49 Mon Sep 17 00:00:00 2001 From: zkldi Date: Wed, 4 May 2022 13:50:15 +0100 Subject: [PATCH 1/3] Update Dockerfile --- server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/Dockerfile b/server/Dockerfile index 66ce5e92c..69301f42d 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /app COPY --chown=node:node . /app RUN npm install --silent -g pnpm && groupmod -g 1003 node && chown node:node /app USER node -RUN pnpm install --silent && pnpm build && pnpm prune --silent --production && pnpm store prune --silent +RUN pnpm install --silent --frozen-lockfile && pnpm build && pnpm prune --silent --production && pnpm store prune --silent HEALTHCHECK --interval=15s --timeout=5s CMD curl -f http://localhost:8080/api/v1/status || exit 1 ENV NODE_PATH=js/ CMD ["node", "js/main.js"] From 1f68a80410bbbf527210b4f0556e7ad963bc831a Mon Sep 17 00:00:00 2001 From: ereti <43418802+ereti@users.noreply.github.com> Date: Fri, 6 May 2022 01:48:46 +0100 Subject: [PATCH 2/3] Update Dockerfile --- server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/Dockerfile b/server/Dockerfile index 69301f42d..8fa52f663 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -5,7 +5,7 @@ FROM node:16 as build WORKDIR /app COPY --chown=node:node . /app -RUN npm install --silent -g pnpm && groupmod -g 1003 node && chown node:node /app +RUN npm install --silent -g pnpm@6 && groupmod -g 1003 node && chown node:node /app USER node RUN pnpm install --silent --frozen-lockfile && pnpm build && pnpm prune --silent --production && pnpm store prune --silent HEALTHCHECK --interval=15s --timeout=5s CMD curl -f http://localhost:8080/api/v1/status || exit 1 From 7adff08b798b74c3415340ff0aede132bf8664de Mon Sep 17 00:00:00 2001 From: zkldi Date: Tue, 31 May 2022 14:03:02 +0100 Subject: [PATCH 3/3] cherry-pick: Merge pull request #719 from TNG-dev/hotfix/v2.1.17 --- .../file/solid-state-squad/parser.test.ts | 37 +++++++++++++++ .../file/solid-state-squad/parser.ts | 32 ++++++++++++- .../test-data/s3/point-five-nine.xml | 47 +++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 server/src/test-utils/test-data/s3/point-five-nine.xml diff --git a/server/src/lib/score-import/import-types/file/solid-state-squad/parser.test.ts b/server/src/lib/score-import/import-types/file/solid-state-squad/parser.test.ts index 03e35637e..245a8723b 100644 --- a/server/src/lib/score-import/import-types/file/solid-state-squad/parser.test.ts +++ b/server/src/lib/score-import/import-types/file/solid-state-squad/parser.test.ts @@ -103,6 +103,43 @@ t.test("#ParseSolidStateXML", (t) => { t.end(); }); + t.test("Should parse S3 XML on the chart .59", (t) => { + const res = ParseSolidStateXML( + MockMulterFile(GetKTDataBuffer("./s3/point-five-nine.xml"), "point-five-nine.xml"), + {}, + logger + ); + + t.hasStrict( + res.iterable, + [ + { + id: 187, + diff: 7, + songname: ".59", + styles: "3rd", + exscore: 100, + scorebreakdown: { + justgreats: 50, + greats: 50, + good: 0, + bad: 0, + poor: 4, + }, + mods: {}, + cleartype: "perfect", + date: "2010-10-19 04:54:22", + }, + ], + "Should return the right score in the iterable." + ); + t.equal(res.game, "iidx", "Should return IIDX as the game."); + t.equal(res.classHandler, null, "Should return no class handler."); + t.strictSame(res.context, {}, "Should return no context."); + + t.end(); + }); + t.test("Should reject S3 XML with no scores", (t) => { t.throws( () => diff --git a/server/src/lib/score-import/import-types/file/solid-state-squad/parser.ts b/server/src/lib/score-import/import-types/file/solid-state-squad/parser.ts index 236a7f580..77abdfbe7 100644 --- a/server/src/lib/score-import/import-types/file/solid-state-squad/parser.ts +++ b/server/src/lib/score-import/import-types/file/solid-state-squad/parser.ts @@ -19,7 +19,19 @@ const PR_SolidState: PrudenceSchema = { { id: p.isPositiveInteger, diff: p.isIn("L7", 7, "A", "B", 5, "L14", 14, "A14", "B14"), - songname: "string", + + // https://github.com/TNG-dev/tachi-server/issues/718 + // The song title '.59' is automatically coerced into a float + // by our XML parser. Despite the fact that it's in a CData field. + // Regardless of the mess that is XML, we need to accept numbers in + // this field, and then convert them back to strings later. + // + // Making a proper solution for this isn't possible, as the bowels + // of the XML parser are inaccessible to us. + // I *hate* XML. + // + // What a disaster. + songname: p.or("string", p.is(0.59)), styles: "string", exscore: p.isPositiveInteger, @@ -52,6 +64,9 @@ const PR_SolidState: PrudenceSchema = { const xmlParser = new XMLParser(); +// .59 is a song that is interpreted as a float by our XML parser. +type PreStringifiedS3Score = Omit & { songname: 0.59 | string }; + export function ParseSolidStateXML( fileData: Express.Multer.File, body: Record, @@ -83,10 +98,23 @@ export function ParseSolidStateXML( throw new ScoreImportFatalError(400, FormatPrError(err, "Invalid S3 XML.")); } + let scoreData = parsedXML.s3data.scoredata.song as PreStringifiedS3Score[]; + + scoreData = scoreData.map((e) => ({ + ...e, + // Songnames here are either numbers or strings due to a disgusting hack + // @see #718 + // We forcibly convert all these back to strings. + // Note that we can't even use the generic solution .toString, because the + // song title is .59, not 0.59. + // This is genuinely horrific. + songname: e.songname === 0.59 ? ".59" : e.songname, + })); + return { classHandler: null, context: {}, - iterable: parsedXML.s3data.scoredata.song as S3Score[], + iterable: scoreData as S3Score[], game: "iidx", }; } diff --git a/server/src/test-utils/test-data/s3/point-five-nine.xml b/server/src/test-utils/test-data/s3/point-five-nine.xml new file mode 100644 index 000000000..63b9c76a0 --- /dev/null +++ b/server/src/test-utils/test-data/s3/point-five-nine.xml @@ -0,0 +1,47 @@ + + + 3 + + + + + + + + + + 187 + 7 + + + + + + + + + + 174 + 3rd + 1 + 137 + 100 + AA + 9 + + 50 + 50 + 0 + 0 + 4 + + + 2 + T + B + + perfect + 2010-10-19 04:54:22 + + + \ No newline at end of file