1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Make country code parsing resilient to invalid cases

This commit is contained in:
Dean Herbert 2022-10-11 01:38:37 +09:00
parent be5a413753
commit d700040a0d
2 changed files with 6 additions and 2 deletions

View File

@ -195,7 +195,7 @@ Line after image";
AddStep("Add flag", () =>
{
markdownContainer.CurrentPath = @"https://dev.ppy.sh";
markdownContainer.Text = "::{flag=\"AU\"}::";
markdownContainer.Text = "::{flag=\"AU\"}:: ::{flag=\"ZZ\"}::";
});
}

View File

@ -57,7 +57,11 @@ namespace osu.Game.Graphics.Containers.Markdown
}
string flag = flagAttribute.Split('=').Last().Trim('"');
AddDrawable(new DrawableFlag(Enum.Parse<CountryCode>(flag)) { Size = new Vector2(20, 15) });
if (!Enum.TryParse<CountryCode>(flag, out var countryCode))
countryCode = CountryCode.Unknown;
AddDrawable(new DrawableFlag(countryCode) { Size = new Vector2(20, 15) });
}
private class OsuMarkdownInlineCode : Container