修复ttml解析bug
This commit is contained in:
parent
dd4577b4cf
commit
6428d94fa0
|
@ -30,7 +30,7 @@ namespace Mp4SubtitleParser
|
||||||
|
|
||||||
public partial class MP4TtmlUtil
|
public partial class MP4TtmlUtil
|
||||||
{
|
{
|
||||||
[RegexGenerator(">(.+?)<\\/p>")]
|
[RegexGenerator("<p.*?>(.+?)<\\/p>")]
|
||||||
private static partial Regex LabelFixRegex();
|
private static partial Regex LabelFixRegex();
|
||||||
|
|
||||||
public static bool CheckInit(byte[] data)
|
public static bool CheckInit(byte[] data)
|
||||||
|
@ -184,10 +184,16 @@ namespace Mp4SubtitleParser
|
||||||
{
|
{
|
||||||
foreach (Match m in regex.Matches(xmlContentFix))
|
foreach (Match m in regex.Matches(xmlContentFix))
|
||||||
{
|
{
|
||||||
if (!m.Groups[1].Value.StartsWith("<span"))
|
try
|
||||||
|
{
|
||||||
|
new XmlDocument().LoadXml($"<p>{m.Groups[1].Value}</p>");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
xmlContentFix = xmlContentFix.Replace(m.Groups[1].Value, System.Web.HttpUtility.HtmlEncode(m.Groups[1].Value));
|
xmlContentFix = xmlContentFix.Replace(m.Groups[1].Value, System.Web.HttpUtility.HtmlEncode(m.Groups[1].Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xmlDoc.LoadXml(xmlContentFix);
|
xmlDoc.LoadXml(xmlContentFix);
|
||||||
var ttNode = xmlDoc.LastChild;
|
var ttNode = xmlDoc.LastChild;
|
||||||
if (nsMgr == null)
|
if (nsMgr == null)
|
||||||
|
|
Loading…
Reference in New Issue