Fix bad xml replace in "TTML 1.0"- thx Info :)

This commit is contained in:
Nikolaj Olsson 2024-08-11 19:11:46 +02:00
parent 1606f7d8d7
commit 1c328acdc8

View File

@ -528,8 +528,21 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
try
{
text = string.Join("<br/>", text.SplitToLines());
XmlDocument paragraphContent = new XmlDocument();
paragraphContent.LoadXml($"<root>{text.Replace("&", "&amp;")}</root>");
var paragraphContent = new XmlDocument();
try
{
paragraphContent.LoadXml($"<root>{text.Replace("&", "&amp;")}</root>");
}
catch
{
var guid = Guid.NewGuid().ToString();
var tempText = text.Replace("&amp;", guid);
tempText = tempText.Replace("&", "&amp;");
tempText = tempText.Replace(guid, "&amp;");
paragraphContent.LoadXml($"<root>{tempText}</root>");
}
ConvertParagraphNodeToTtmlNode(paragraphContent.DocumentElement, xml, paragraph);
}
catch // Wrong markup, clear it