From 1c328acdc80addf176a2740833648b60c00642b9 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sun, 11 Aug 2024 19:11:46 +0200 Subject: [PATCH] Fix bad xml replace in "TTML 1.0"- thx Info :) --- src/libse/SubtitleFormats/TimedText10.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libse/SubtitleFormats/TimedText10.cs b/src/libse/SubtitleFormats/TimedText10.cs index 9f71fd677..3154c70c2 100644 --- a/src/libse/SubtitleFormats/TimedText10.cs +++ b/src/libse/SubtitleFormats/TimedText10.cs @@ -528,8 +528,21 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats try { text = string.Join("
", text.SplitToLines()); - XmlDocument paragraphContent = new XmlDocument(); - paragraphContent.LoadXml($"{text.Replace("&", "&")}"); + var paragraphContent = new XmlDocument(); + + try + { + paragraphContent.LoadXml($"{text.Replace("&", "&")}"); + } + catch + { + var guid = Guid.NewGuid().ToString(); + var tempText = text.Replace("&", guid); + tempText = tempText.Replace("&", "&"); + tempText = tempText.Replace(guid, "&"); + paragraphContent.LoadXml($"{tempText}"); + } + ConvertParagraphNodeToTtmlNode(paragraphContent.DocumentElement, xml, paragraph); } catch // Wrong markup, clear it