mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Backport pull request #13092 from jellyfin/release-10.10.z
Fix: handling of <set> elements in NfoParser Original-merge: f333ef74b3cc8444e12ac1210f94daf59c766969 Merged-by: joshuaboniface <joshua@boniface.me> Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
parent
cfeb879519
commit
51207edf44
@ -82,21 +82,13 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val) && movie is not null)
|
||||
{
|
||||
// TODO Handle this better later
|
||||
if (!val.Contains('<', StringComparison.Ordinal))
|
||||
try
|
||||
{
|
||||
movie.CollectionName = val;
|
||||
ParseSetXml(val, movie);
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
ParseSetXml(val, movie);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error parsing set node");
|
||||
}
|
||||
Logger.LogError(ex, "Error parsing set node");
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +131,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||
// Loop through each element
|
||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
if (reader.NodeType == XmlNodeType.Text && reader.Depth == 1)
|
||||
{
|
||||
movie.CollectionName = reader.Value;
|
||||
break;
|
||||
}
|
||||
else if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
switch (reader.Name)
|
||||
{
|
||||
|
@ -115,7 +115,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||
{
|
||||
if (!string.IsNullOrEmpty(movie.CollectionName))
|
||||
{
|
||||
writer.WriteElementString("set", movie.CollectionName);
|
||||
writer.WriteStartElement("set");
|
||||
writer.WriteElementString("name", movie.CollectionName);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,5 +257,23 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _parser.Fetch(result, string.Empty, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parsing_Fields_With_Escaped_Xml_Special_Characters_Success()
|
||||
{
|
||||
var result = new MetadataResult<Video>()
|
||||
{
|
||||
Item = new Movie()
|
||||
};
|
||||
|
||||
_parser.Fetch(result, "Test Data/Lilo & Stitch.nfo", CancellationToken.None);
|
||||
var item = (Movie)result.Item;
|
||||
|
||||
Assert.Equal("Lilo & Stitch", item.Name);
|
||||
Assert.Equal("Lilo & Stitch", item.OriginalTitle);
|
||||
Assert.Equal("Lilo & Stitch Collection", item.CollectionName);
|
||||
Assert.StartsWith(">>", item.Overview, StringComparison.InvariantCulture);
|
||||
Assert.EndsWith("<<", item.Overview, StringComparison.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<movie>
|
||||
<title>Lilo & Stitch</title>
|
||||
<originaltitle>Lilo & Stitch</originaltitle>
|
||||
<set>Lilo & Stitch Collection</set>
|
||||
<plot>>>As Stitch, a runaway genetic experiment from a faraway planet, wreaks havoc on the Hawaiian Islands, he becomes the mischievous adopted alien "puppy" of an independent little girl named Lilo and learns about loyalty, friendship, and ʻohana, the Hawaiian tradition of family.<<</plot>
|
||||
</movie>
|
Loading…
x
Reference in New Issue
Block a user