Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions docs/docset.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
project: 'doc-builder'
cross_links:
- docs-content
# docs-builder will warn for links to external hosts not declared here
external_hosts:
- slack.com
- mystmd.org
- microsoft.com
- azure.com
- mistral.ai
- amazon.com
- python.org
- cohere.com
- docker.com
- langchain.com
- nodejs.org
- yarnpkg.com
- react.dev
- palletsprojects.com
- google.com
- checkvist.com
- commonmark.org
- github.io
- github.com
- pandoc.org
- atlassian.net
- elastic.dev
- visualstudio.com
- wikipedia.org
exclude:
- '_*.md'
subs:
Expand Down
10 changes: 3 additions & 7 deletions src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public record ConfigurationFile : DocumentationFile
public HashSet<string> Files { get; } = new(StringComparer.OrdinalIgnoreCase);
public HashSet<string> ImplicitFolders { get; } = new(StringComparer.OrdinalIgnoreCase);
public Glob[] Globs { get; } = [];
public HashSet<string> ExternalLinkHosts { get; } = new(StringComparer.OrdinalIgnoreCase) { "elastic.co", "github.com", "localhost", };

private readonly Dictionary<string, string> _substitutions = new(StringComparer.OrdinalIgnoreCase);
public IReadOnlyDictionary<string, string> Substitutions => _substitutions;
Expand Down Expand Up @@ -80,12 +79,6 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon
case "subs":
_substitutions = ReadDictionary(entry);
break;
case "external_hosts":
var hosts = ReadStringArray(entry)
.ToArray();
foreach (var host in hosts)
ExternalLinkHosts.Add(host);
break;
case "toc":
if (depth > 1)
{
Expand All @@ -97,6 +90,9 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon

TableOfContents = entries;
break;
case "external_hosts":
EmitWarning($"{key} has been deprecated and will be removed", entry.Key);
break;
default:
EmitWarning($"{key} is not a known configuration", entry.Key);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,11 @@ private bool ValidateExternalUri(LinkInline link, InlineProcessor processor, Par
return false;

var baseDomain = uri.Host == "localhost" ? "localhost" : string.Join('.', uri.Host.Split('.')[^2..]);
if (!context.Configuration.ExternalLinkHosts.Contains(baseDomain))
if (uri.Scheme == "mailto" && baseDomain != "elastic.co")
{
processor.EmitWarning(
link,
$"External URI '{uri}' is not allowed. Add '{baseDomain}' to the " +
$"'external_hosts' list in the configuration file '{context.Configuration.SourceFile}' " +
"to allow links to this domain."
$"mailto links should be to elastic.co domains. Found {uri.Host} in {link.Url}. "
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/authoring/Inline/InlineLinks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ``inline link with mailto not allowed external host`` () =
let ``has no errors`` () = markdown |> hasNoErrors

[<Fact>]
let ``has warning`` () = markdown |> hasWarning "External URI 'mailto:fake-email@somehost.co' is not allowed."
let ``has warning`` () = markdown |> hasWarning "mailto links should be to elastic.co domains."

type ``empty link should result in an error`` () =

Expand Down