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

@ -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