mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 04:52:57 +08:00
Show error message on attempting to open a URL with an unsupported protocol
This commit is contained in:
parent
cbd7cae70a
commit
bf56f5f8c0
@ -26,6 +26,16 @@ namespace osu.Game.Tests.Chat
|
||||
MessageFormatter.WebsiteRootUrl = originalWebsiteRootUrl;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnsupportedProtocolLink()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a gopher://really-old-protocol we don't support." });
|
||||
|
||||
Assert.AreEqual(result.Content, result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("gopher://really-old-protocol", result.Links[0].Url);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBareLink()
|
||||
{
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user