mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Perform proxying only on osu! markdown images
This commit is contained in:
parent
2a7133d6d3
commit
9a89d402b9
@ -17,5 +17,8 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
TooltipText = linkInline.Title;
|
||||
}
|
||||
|
||||
protected override ImageContainer CreateImageContainer(string url)
|
||||
=> base.CreateImageContainer($@"https://osu.ppy.sh/beatmapsets/discussions/media-url?url={url}");
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,10 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="OnlineStore"/> which proxies external media lookups through osu-web.
|
||||
/// </summary>
|
||||
public class OsuOnlineStore : OnlineStore
|
||||
{
|
||||
private readonly string apiEndpointUrl;
|
||||
@ -20,8 +18,11 @@ namespace osu.Game.Online
|
||||
|
||||
protected override string GetLookupUrl(string url)
|
||||
{
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out Uri? uri) && uri.Host.EndsWith(@".ppy.sh", StringComparison.OrdinalIgnoreCase))
|
||||
return url;
|
||||
if (!Uri.TryCreate(url, UriKind.Absolute, out Uri? uri) || !uri.Host.EndsWith(@".ppy.sh", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Logger.Log($@"Blocking resource lookup from external website: {url}", LoggingTarget.Network, LogLevel.Important);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return $@"{apiEndpointUrl}/beatmapsets/discussions/media-url?url={url}";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user