Skip to content

Commit 1f23af0

Browse files
authored
Remove ExternalLinkHosts validation (#514)
* Remove ExternalLinkHosts validation We still validate mailto links, these may only link to elastic.co addresses (hardcoded). * remove external_hosts from docset.yml
1 parent c09209c commit 1f23af0

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

docs/docset.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
project: 'doc-builder'
22
cross_links:
33
- docs-content
4-
# docs-builder will warn for links to external hosts not declared here
5-
external_hosts:
6-
- slack.com
7-
- mystmd.org
8-
- microsoft.com
9-
- azure.com
10-
- mistral.ai
11-
- amazon.com
12-
- python.org
13-
- cohere.com
14-
- docker.com
15-
- langchain.com
16-
- nodejs.org
17-
- yarnpkg.com
18-
- react.dev
19-
- palletsprojects.com
20-
- google.com
21-
- checkvist.com
22-
- commonmark.org
23-
- github.io
24-
- github.com
25-
- pandoc.org
26-
- atlassian.net
27-
- elastic.dev
28-
- visualstudio.com
29-
- wikipedia.org
304
exclude:
315
- '_*.md'
326
subs:

src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public record ConfigurationFile : DocumentationFile
2626
public HashSet<string> Files { get; } = new(StringComparer.OrdinalIgnoreCase);
2727
public HashSet<string> ImplicitFolders { get; } = new(StringComparer.OrdinalIgnoreCase);
2828
public Glob[] Globs { get; } = [];
29-
public HashSet<string> ExternalLinkHosts { get; } = new(StringComparer.OrdinalIgnoreCase) { "elastic.co", "github.com", "localhost", };
3029

3130
private readonly Dictionary<string, string> _substitutions = new(StringComparer.OrdinalIgnoreCase);
3231
public IReadOnlyDictionary<string, string> Substitutions => _substitutions;
@@ -80,12 +79,6 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon
8079
case "subs":
8180
_substitutions = ReadDictionary(entry);
8281
break;
83-
case "external_hosts":
84-
var hosts = ReadStringArray(entry)
85-
.ToArray();
86-
foreach (var host in hosts)
87-
ExternalLinkHosts.Add(host);
88-
break;
8982
case "toc":
9083
if (depth > 1)
9184
{
@@ -97,6 +90,9 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon
9790

9891
TableOfContents = entries;
9992
break;
93+
case "external_hosts":
94+
EmitWarning($"{key} has been deprecated and will be removed", entry.Key);
95+
break;
10096
default:
10197
EmitWarning($"{key} is not a known configuration", entry.Key);
10298
break;

src/Elastic.Markdown/Myst/InlineParsers/DiagnosticLinkInlineParser.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ private bool ValidateExternalUri(LinkInline link, InlineProcessor processor, Par
143143
return false;
144144

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

tests/authoring/Inline/InlineLinks.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type ``inline link with mailto not allowed external host`` () =
4545
let ``has no errors`` () = markdown |> hasNoErrors
4646

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

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

0 commit comments

Comments
 (0)