writeChartFile: re-quote extraChartSongFields per .chart spec types - #89
Open
elicwhite wants to merge 1 commit into
Open
writeChartFile: re-quote extraChartSongFields per .chart spec types#89elicwhite wants to merge 1 commit into
elicwhite wants to merge 1 commit into
Conversation
The parser strips enclosing quotes from `[Song]` values on read, so `extraChartSongFields` always holds bare strings. Emitting them verbatim produced `MusicStream = song.ogg` (unquoted) — Moonscraper rejects that shape and fails to load the audio. Re-apply quoting on write per the spec's field-type table: - `Player2` (the lone `bare string` field) stays bare. - Numeric and boolean primitives stay bare via value-shape check. - Everything else gets quoted. The default-quote-strings rule is verified across a 62K-chart corpus: every `string` / `file path` field is quoted ≥99.97% of the time, and the only de-facto boolean field (`OriginalArtist = false`) appears unquoted in 171/171 occurrences.
elicwhite
changed the base branch from
master
to
skip-default-keys-in-ini-writer
April 28, 2026 20:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #87 and the writer stack below it. Standalone of the stack, the change is ~30 lines.
Summary
The chart parser strips enclosing quotes from
[Song]values on read (chart-parser.ts'schartSongMetaRegex = /^(.+?) = "?(.*?)"?$/), sometadata.extraChartSongFieldsalways holds bare strings. The writer was emitting them verbatim — which producesMusicStream = song.ogg(unquoted). Moonscraper rejects that shape and silently fails to load audio, so any chart edited and re-saved viawriteChartFilecame back broken.Changes
writeChartFilere-applies quoting on emit per the .chart spec's field-type table at Format-Overview.md (lines 78-85, 143-199):Player2— the spec's lonebare stringfield — stays bare via a small allowlist./^(?:-?\d+(?:\.\d+)?|true|false)$/).stringandfile pathfield is quoted) and mirrors what readers (Moonscraper, scan-chart) tolerate.The parser is untouched, so the
extraChartSongFieldsshape stays "always bare" — callers don't have to think about quoting.Why these rules
Verified across a 62,697-chart corpus (Encore + remaining-charts dumps). For every well-known string-typed
[Song]key, ≥99.97% of occurrences are quoted; outlier counts are 3-5 per key (sloppy authoring, not a real divergence). Stream filenames specifically are quoted 100% of the time. The only de-facto boolean field in the corpus,OriginalArtist, appears asOriginalArtist = falsein 171/171 charts that use it — covered by the boolean branch of the value-shape regex.Test plan
round-trip-unrecognized-extras.test.ts:MusicStreamemits with quotes Moonscraper expects (pins on-disk text).Player2emits unquoted (bare-string field per spec).HoPo,PreviewEnd) emit unquoted.