mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix FormattedMessage not escaping text when converted to markup
Meant that ToMarkup() wasn't actually round-trip safe.
This commit is contained in:
@@ -44,7 +44,7 @@ END TEMPLATE-->
|
||||
|
||||
### Bugfixes
|
||||
|
||||
*None yet*
|
||||
* Fixed `FormattedMessage` not escaping plain text content properly with `.ToMarkup()`.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed class MarkupNode : IComparable<MarkupNode>, IEquatable<MarkupNode>
|
||||
public override string ToString()
|
||||
{
|
||||
if(Name == null)
|
||||
return Value.StringValue ?? "";
|
||||
return FormattedMessage.EscapeText(Value.StringValue ?? "");
|
||||
|
||||
var attributesString = "";
|
||||
foreach (var (k, v) in Attributes)
|
||||
|
||||
@@ -83,5 +83,18 @@ namespace Robust.UnitTesting.Shared.Utility
|
||||
message.EnumerateRunes(),
|
||||
Is.EquivalentTo(message.ToString().EnumerateRunes()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that the given formatted message string provides equal result when output & parsed again.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[TestCase("\\[whaaaaa")]
|
||||
public static void TestRoundTrip(string markup)
|
||||
{
|
||||
var message = FormattedMessage.FromMarkupOrThrow(markup);
|
||||
var secondMessage = FormattedMessage.FromMarkupOrThrow(message.ToMarkup());
|
||||
|
||||
Assert.That(secondMessage, NUnit.Framework.Is.EqualTo(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user