mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:07:52 +08:00
Merge pull request #12058 from peppy/fix-whitespace-in-ini
Fix skin parser not stripping whitespace before parsing
This commit is contained in:
commit
53ae24db9b
2
osu.Game.Tests/Resources/skin-with-space.ini
Normal file
2
osu.Game.Tests/Resources/skin-with-space.ini
Normal file
@ -0,0 +1,2 @@
|
||||
[General]
|
||||
Version: 2
|
@ -91,6 +91,15 @@ namespace osu.Game.Tests.Skins
|
||||
Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStripWhitespace()
|
||||
{
|
||||
var decoder = new LegacySkinDecoder();
|
||||
using (var resStream = TestResources.OpenResource("skin-with-space.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeLatestVersion()
|
||||
{
|
||||
|
@ -67,16 +67,14 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
protected override void ParseLine(Beatmap beatmap, Section section, string line)
|
||||
{
|
||||
var strippedLine = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
handleGeneral(strippedLine);
|
||||
handleGeneral(line);
|
||||
return;
|
||||
|
||||
case Section.Editor:
|
||||
handleEditor(strippedLine);
|
||||
handleEditor(line);
|
||||
return;
|
||||
|
||||
case Section.Metadata:
|
||||
@ -84,19 +82,19 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return;
|
||||
|
||||
case Section.Difficulty:
|
||||
handleDifficulty(strippedLine);
|
||||
handleDifficulty(line);
|
||||
return;
|
||||
|
||||
case Section.Events:
|
||||
handleEvent(strippedLine);
|
||||
handleEvent(line);
|
||||
return;
|
||||
|
||||
case Section.TimingPoints:
|
||||
handleTimingPoint(strippedLine);
|
||||
handleTimingPoint(line);
|
||||
return;
|
||||
|
||||
case Section.HitObjects:
|
||||
handleHitObject(strippedLine);
|
||||
handleHitObject(line);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
if (ShouldSkipLine(line))
|
||||
continue;
|
||||
|
||||
line = StripComments(line).TrimEnd();
|
||||
|
||||
if (line.StartsWith('[') && line.EndsWith(']'))
|
||||
{
|
||||
if (!Enum.TryParse(line[1..^1], out section))
|
||||
@ -71,8 +73,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
protected virtual void ParseLine(T output, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.Colours:
|
||||
|
@ -45,8 +45,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
|
@ -31,8 +31,6 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected override void ParseLine(List<LegacyManiaSkinConfiguration> output, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.Mania:
|
||||
|
Loading…
Reference in New Issue
Block a user