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:
parent
be5a413753
commit
d700040a0d
@ -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\"}::";
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user