Skip to content

Commit d724d1a

Browse files
committed
adding an allowlist for epr links
1 parent 891db7c commit d724d1a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Elastic.Markdown/Myst/Directives/Image/ImageBlock.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class ImageBlock(DirectiveBlockParser parser, ParserContext context)
6868

6969
public string? Label { get; private set; }
7070

71+
private static readonly string[] AllowedUriList = ["epr.elastic.co"];
72+
7173
public override void FinalizeAndValidate(ParserContext context)
7274
{
7375
Label = Prop("label", "name");
@@ -98,7 +100,9 @@ private void ExtractImageUrl(ParserContext context)
98100

99101
if (Uri.TryCreate(imageUrl, UriKind.Absolute, out var uri) && uri.Scheme.StartsWith("http"))
100102
{
101-
this.EmitWarning($"{Directive} is using an external URI: {uri} ");
103+
if (!AllowedUriList.Any(host => uri.Host.Contains(host)))
104+
this.EmitWarning($"{Directive} is using an external URI: {uri} ");
105+
102106
Found = true;
103107
ImageUrl = imageUrl;
104108
return;

0 commit comments

Comments
 (0)