mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
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:
@ -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()
|
||||
{
|
||||
|
Reference in New Issue
Block a user