mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-13 17:26:08 +03:00
fix(edit logging): sanitize input text
This commit is contained in:
parent
e6f53b13f0
commit
2359feca7d
2 changed files with 15 additions and 3 deletions
|
@ -12,17 +12,17 @@ public static class DiffPaneModelExtensions
|
||||||
{
|
{
|
||||||
if (line.Type is ChangeType.Deleted)
|
if (line.Type is ChangeType.Deleted)
|
||||||
{
|
{
|
||||||
builder.Append("- ");
|
builder.Append("-- ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.Type is ChangeType.Inserted)
|
if (line.Type is ChangeType.Inserted)
|
||||||
{
|
{
|
||||||
builder.Append("+ ");
|
builder.Append("++ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.Type is not ChangeType.Imaginary)
|
if (line.Type is not ChangeType.Imaginary)
|
||||||
{
|
{
|
||||||
builder.AppendLine(line.Text);
|
builder.AppendLine(line.Text.SanitizeForDiffBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,18 @@ public static class StringExtensions
|
||||||
return s.Replace("```", "```");
|
return s.Replace("```", "```");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sanitizes a string for use in <see cref="Markdown.BlockCode(string, string)" /> when "language" is "diff" by
|
||||||
|
/// prepending a zero-width space before syntax highlighting characters (+ and -).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This does not call <see cref="SanitizeForBlockCode"/>, you have to do so yourself if needed.</remarks>
|
||||||
|
/// <param name="s">The string to sanitize.</param>
|
||||||
|
/// <returns>The sanitized string that can be safely used in <see cref="Markdown.BlockCode(string, string)" /> with "diff" as the language.</returns>
|
||||||
|
public static string SanitizeForDiffBlock(this string s)
|
||||||
|
{
|
||||||
|
return $"{s}";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string to use Markdown Block Code
|
/// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string to use Markdown Block Code
|
||||||
/// formatting with a specified
|
/// formatting with a specified
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue