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 try
{ {
text = string.Join("<br/>", text.SplitToLines()); text = string.Join("<br/>", text.SplitToLines());
XmlDocument paragraphContent = new XmlDocument(); var paragraphContent = new XmlDocument();
paragraphContent.LoadXml($"<root>{text.Replace("&", "&amp;")}</root>");
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); ConvertParagraphNodeToTtmlNode(paragraphContent.DocumentElement, xml, paragraph);
} }
catch // Wrong markup, clear it catch // Wrong markup, clear it