diff --git a/libse/SubtitleFormats/TimedText.cs b/libse/SubtitleFormats/TimedText.cs index a177c93ead..452d34f23e 100644 --- a/libse/SubtitleFormats/TimedText.cs +++ b/libse/SubtitleFormats/TimedText.cs @@ -38,11 +38,11 @@ public override bool IsMine(List lines, string fileName) var xml = new XmlDocument { XmlResolver = null }; try { - xml.LoadXml(xmlAsString); + xml.LoadXml(xmlAsString.Replace(" & ", " & ").Replace("Q&A", "Q&A")); var nsmgr = new XmlNamespaceManager(xml.NameTable); nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI); - XmlNode div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr); + var div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr); if (div == null) div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).FirstChild; int numberOfParagraphs = div.ChildNodes.Count; @@ -135,12 +135,12 @@ public override void LoadSubtitle(Subtitle subtitle, List lines, string var sb = new StringBuilder(); lines.ForEach(line => sb.AppendLine(line)); var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().RemoveControlCharactersButWhiteSpace().Trim()); + xml.LoadXml(sb.ToString().Replace(" & ", " & ").Replace("Q&A", "Q&A").RemoveControlCharactersButWhiteSpace().Trim()); var nsmgr = new XmlNamespaceManager(xml.NameTable); nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI); - XmlNode div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr); + var div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr); if (div == null) div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).FirstChild; @@ -313,7 +313,7 @@ public override void LoadSubtitle(Subtitle subtitle, List lines, string } } } - else if (couldBeMillisecondsWithMissingLastDigit && Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource != "hh:mm:ss.ms-two-digits") + else if (couldBeMillisecondsWithMissingLastDigit && Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource != "hh:mm:ss.ms-two-digits") { foreach (Paragraph p in subtitle.Paragraphs) {