Resolve link-in-link edge case

Testing with #6542 surfaced a crash scenario, caused by formatted links
that had URLs in the display text, for example

    [mean example - https://osu.ppy.sh](https://osu.ppy.sh)

In that case the outer Markdown link would get picked up once, and then
reduced to the link text when looking for other links, leading to it
being picked up again the second time when the raw link is found.

Add a check in the raw link parsing path that ensures that the found
URL is not a part of a bigger, pre-existing link.
This commit is contained in:
Bartłomiej Dach
2019-10-22 01:01:37 +02:00
parent 24b7160522
commit cbd99cc767
2 changed files with 25 additions and 5 deletions

View File

@ -309,6 +309,18 @@ namespace osu.Game.Tests.Chat
Assert.AreEqual(18, result.Links[0].Length);
}
[Test]
public void TestMarkdownFormatLinkWithUrlAndTextInTitle()
{
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [oh no, text here! https://osu.ppy.sh](https://osu.ppy.sh) before..." });
Assert.AreEqual("I haven't seen oh no, text here! https://osu.ppy.sh before...", result.DisplayContent);
Assert.AreEqual(1, result.Links.Count);
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
Assert.AreEqual(15, result.Links[0].Index);
Assert.AreEqual(36, result.Links[0].Length);
}
[Test]
public void TestMarkdownFormatLinkWithMisleadingUrlInText()
{