Skip to content

Commit

Permalink
Minor fix for badly encoded Timed Text Draft files
Browse files Browse the repository at this point in the history
  • Loading branch information
niksedk committed Dec 12, 2016
1 parent 5347fa5 commit cb1b2d9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libse/SubtitleFormats/TimedText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public override bool IsMine(List<string> lines, string fileName)
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsString);
xml.LoadXml(xmlAsString.Replace(" & ", " &amp; ").Replace("Q&A", "Q&amp;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;
Expand Down Expand Up @@ -135,12 +135,12 @@ public override void LoadSubtitle(Subtitle subtitle, List<string> 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(" & ", " &amp; ").Replace("Q&A", "Q&amp;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;

Expand Down Expand Up @@ -313,7 +313,7 @@ public override void LoadSubtitle(Subtitle subtitle, List<string> 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)
{
Expand Down

0 comments on commit cb1b2d9

Please sign in to comment.