Skip to content

Commit afb7679

Browse files
authored
Merge pull request #9238 from NuGet/main
[ReleasePrep][2022.09.16]FI of main into dev
2 parents acedff0 + ea0aaf1 commit afb7679

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/NuGetGallery/Services/MarkdownService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private RenderedMarkdownResult GetHtmlFromMarkdownMarkdig(string markdownString,
268268
// Allow only http or https links in markdown. Transform link to https for known domains.
269269
if (!PackageHelper.TryPrepareUrlForRendering(linkInline.Url, out string readyUriString))
270270
{
271-
if (!linkInline.Url.StartsWith("#")) //allow internal section links
271+
if (linkInline.Url != null && !linkInline.Url.StartsWith("#")) //allow internal section links
272272
{
273273
linkInline.Url = string.Empty;
274274
}

tests/NuGetGallery.Facts/Services/MarkdownServiceFacts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ Some text
226226
[Theory]
227227
[InlineData("This is a http://www.google.com URL and https://www.google.com", "<p>This is a <a href=\"http://www.google.com/\" rel=\"noopener noreferrer nofollow\">http://www.google.com</a> URL and <a href=\"https://www.google.com/\" rel=\"noopener noreferrer nofollow\">https://www.google.com</a></p>")]
228228
[InlineData("# This is a heading\n[Link](#this-is-a-heading)", "<h2 id=\"this-is-a-heading\">This is a heading</h2>\n<p><a href=\"#this-is-a-heading\" rel=\"noopener noreferrer nofollow\">Link</a></p>")]
229+
[InlineData("# Heading\n[Heading]", "<h2 id=\"heading\">Heading</h2>\n<p><a href=\"#heading\" rel=\"noopener noreferrer nofollow\">Heading</a></p>")]
229230
public void TestToHtmlWithAutoLinks(string originalMd, string expectedHtml)
230231
{
231232
_featureFlagService.Setup(x => x.IsMarkdigMdRenderingEnabled()).Returns(true);

0 commit comments

Comments
 (0)