Show error message on attempting to open a URL with an unsupported protocol

This commit is contained in:
Dean Herbert
2022-12-12 18:27:14 +09:00
parent cbd7cae70a
commit bf56f5f8c0
2 changed files with 21 additions and 0 deletions

View File

@ -16,6 +16,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
@ -406,6 +407,16 @@ namespace osu.Game
if (url.StartsWith('/'))
url = $"{API.APIEndpointUrl}{url}";
if (!url.CheckIsValidUrl())
{
Notifications.Post(new SimpleErrorNotification
{
Text = $"The URL {url} has an unsupported or dangerous protocol and will not be opened.",
});
return;
}
externalLinkOpener.OpenUrlExternally(url, bypassExternalUrlWarning);
});