Fix #872 by reserve null title string.

This commit is contained in:
Fa鸽
2025-05-31 16:01:42 +08:00
parent 3535701d70
commit 47c4e9b1e2
3 changed files with 20 additions and 2 deletions

View File

@@ -465,6 +465,24 @@ public static class HtmlHelper
}
}
/// <summary>
/// Destructively unescape a string: remove backslashes before punctuation or symbol characters.
/// </summary>
/// <param name="text">The string data that will be changed by unescaping any punctuation or symbol characters.</param>
/// <param name="removeBackSlash">if set to <c>true</c> [remove back slash].</param>
/// <returns>Unescaped text, or null if <paramref name="text"/> is null.<returns>
public static string? UnescapeNullable(string? text, bool removeBackSlash = true)
{
if (text == null)
{
return null;
}
else
{
return Unescape(text, removeBackSlash);
}
}
/// <summary>
/// Destructively unescape a string: remove backslashes before punctuation or symbol characters.
/// </summary>

View File

@@ -411,7 +411,7 @@ public static class LinkHelper
{
// Skip ')'
text.SkipChar();
title ??= string.Empty;
// not to normalize nulls
}
return isValid;

View File

@@ -260,7 +260,7 @@ public class LinkInlineParser : InlineParser
link = new LinkInline()
{
Url = HtmlHelper.Unescape(url, removeBackSlash: false),
Title = HtmlHelper.Unescape(title, removeBackSlash: false),
Title = HtmlHelper.UnescapeNullable(title, removeBackSlash: false),
IsImage = openParent.IsImage,
LabelSpan = openParent.LabelSpan,
UrlSpan = inlineState.GetSourcePositionFromLocalSpan(linkSpan),