diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs index 8f91626d48..4ce047172e 100644 --- a/Emby.Dlna/Service/BaseControlHandler.cs +++ b/Emby.Dlna/Service/BaseControlHandler.cs @@ -16,7 +16,7 @@ namespace Emby.Dlna.Service public abstract class BaseControlHandler { private const string NS_SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/"; - + protected readonly IServerConfigurationManager Config; protected readonly ILogger Logger; protected readonly IXmlReaderSettingsFactory XmlReaderSettingsFactory; @@ -109,7 +109,7 @@ namespace Emby.Dlna.Service } var xml = builder.ToString().Replace("xmlns:m=", "xmlns:u="); - + var controlResponse = new ControlResponse { Xml = xml, @@ -136,12 +136,20 @@ namespace Emby.Dlna.Service switch (reader.LocalName) { case "Body": - { - using (var subReader = reader.ReadSubtree()) { - return ParseBodyTag(subReader); + if (!reader.IsEmptyElement) + { + using (var subReader = reader.ReadSubtree()) + { + return ParseBodyTag(subReader); + } + } + else + { + reader.Read(); + } + break; } - } default: { reader.Skip(); @@ -173,11 +181,18 @@ namespace Emby.Dlna.Service result.LocalName = reader.LocalName; result.NamespaceURI = reader.NamespaceURI; - using (var subReader = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - result.Headers = ParseFirstBodyChild(subReader); + using (var subReader = reader.ReadSubtree()) + { + result.Headers = ParseFirstBodyChild(subReader); - return result; + return result; + } + } + else + { + reader.Read(); } } else diff --git a/Emby.Server.Implementations/News/NewsEntryPoint.cs b/Emby.Server.Implementations/News/NewsEntryPoint.cs index 51016f2881..53c862d470 100644 --- a/Emby.Server.Implementations/News/NewsEntryPoint.cs +++ b/Emby.Server.Implementations/News/NewsEntryPoint.cs @@ -134,10 +134,18 @@ namespace Emby.Server.Implementations.News { case "channel": { - using (var subReader = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - return ParseFromChannelNode(subReader); + using (var subReader = reader.ReadSubtree()) + { + return ParseFromChannelNode(subReader); + } } + else + { + reader.Read(); + } + break; } default: { @@ -170,9 +178,16 @@ namespace Emby.Server.Implementations.News { case "item": { - using (var subReader = reader.ReadSubtree()) + if (!reader.IsEmptyElement) + { + using (var subReader = reader.ReadSubtree()) + { + list.Add(ParseItem(subReader)); + } + } + else { - list.Add(ParseItem(subReader)); + reader.Read(); } break; } diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index 43a0783165..d66cdf801c 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -395,18 +395,32 @@ namespace MediaBrowser.LocalMetadata.Parsers case "TagLines": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromTaglinesNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromTaglinesNode(subtree, item); + } + } + else + { + reader.Read(); } break; } case "Countries": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromCountriesNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromCountriesNode(subtree, item); + } + } + else + { + reader.Read(); } break; } @@ -592,14 +606,21 @@ namespace MediaBrowser.LocalMetadata.Parsers case "Trailers": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - var hasTrailers = item as IHasTrailers; - if (hasTrailers != null) + using (var subtree = reader.ReadSubtree()) { - FetchDataFromTrailersNode(subtree, hasTrailers); + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) + { + FetchDataFromTrailersNode(subtree, hasTrailers); + } } } + else + { + reader.Read(); + } break; } @@ -699,59 +720,101 @@ namespace MediaBrowser.LocalMetadata.Parsers case "Genres": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) + { + using (var subtree = reader.ReadSubtree()) + { + FetchFromGenresNode(subtree, item); + } + } + else { - FetchFromGenresNode(subtree, item); + reader.Read(); } break; } case "Tags": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromTagsNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromTagsNode(subtree, item); + } + } + else + { + reader.Read(); } break; } case "PlotKeywords": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromKeywordsNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromKeywordsNode(subtree, item); + } + } + else + { + reader.Read(); } break; } case "Persons": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchDataFromPersonsNode(subtree, itemResult); + using (var subtree = reader.ReadSubtree()) + { + FetchDataFromPersonsNode(subtree, itemResult); + } + } + else + { + reader.Read(); } break; } case "Studios": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromStudiosNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromStudiosNode(subtree, item); + } + } + else + { + reader.Read(); } break; } case "Shares": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - var hasShares = item as IHasShares; - if (hasShares != null) + using (var subtree = reader.ReadSubtree()) { - FetchFromSharesNode(subtree, hasShares); + var hasShares = item as IHasShares; + if (hasShares != null) + { + FetchFromSharesNode(subtree, hasShares); + } } } + else + { + reader.Read(); + } break; } @@ -824,6 +887,11 @@ namespace MediaBrowser.LocalMetadata.Parsers { case "Share": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { var share = GetShareFromNode(subtree); @@ -1090,6 +1158,11 @@ namespace MediaBrowser.LocalMetadata.Parsers case "Person": case "Actor": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { foreach (var person in GetPersonsFromXmlNode(subtree)) diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs index d4334bf629..695fe2b12d 100644 --- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs @@ -43,17 +43,31 @@ namespace MediaBrowser.LocalMetadata.Parsers case "PlaylistItems": - using (var subReader = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromCollectionItemsNode(subReader, item); + using (var subReader = reader.ReadSubtree()) + { + FetchFromCollectionItemsNode(subReader, item); + } + } + else + { + reader.Read(); } break; case "Shares": - using (var subReader = reader.ReadSubtree()) + if (!reader.IsEmptyElement) + { + using (var subReader = reader.ReadSubtree()) + { + FetchFromSharesNode(subReader, item); + } + } + else { - FetchFromSharesNode(subReader, item); + reader.Read(); } break; @@ -79,6 +93,12 @@ namespace MediaBrowser.LocalMetadata.Parsers { case "PlaylistItem": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } + using (var subReader = reader.ReadSubtree()) { var child = GetLinkedChild(subReader); @@ -123,6 +143,12 @@ namespace MediaBrowser.LocalMetadata.Parsers { case "Share": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } + using (var subReader = reader.ReadSubtree()) { var child = GetShare(subReader); diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 2b3479b768..de055146a8 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -218,6 +218,11 @@ namespace MediaBrowser.MediaEncoding.Probing switch (reader.Name) { case "dict": + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { ReadFromDictNode(subtree, info); @@ -279,9 +284,14 @@ namespace MediaBrowser.MediaEncoding.Probing } break; case "array": - if (!string.IsNullOrWhiteSpace(currentKey)) + if (reader.IsEmptyElement) { - using (var subtree = reader.ReadSubtree()) + reader.Read(); + continue; + } + using (var subtree = reader.ReadSubtree()) + { + if (!string.IsNullOrWhiteSpace(currentKey)) { pairs.AddRange(ReadValueArray(subtree)); } @@ -315,6 +325,12 @@ namespace MediaBrowser.MediaEncoding.Probing switch (reader.Name) { case "dict": + + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { var dict = GetNameValuePair(subtree); diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 36371e3010..ec31824db9 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -274,6 +274,11 @@ namespace MediaBrowser.Providers.Music { case "release-list": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subReader = reader.ReadSubtree()) { return ParseReleaseList(subReader); @@ -311,6 +316,11 @@ namespace MediaBrowser.Providers.Music { case "release": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } var releaseId = reader.GetAttribute("id"); using (var subReader = reader.ReadSubtree()) @@ -435,6 +445,11 @@ namespace MediaBrowser.Providers.Music { case "release-group-list": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subReader = reader.ReadSubtree()) { return GetFirstReleaseGroupId(subReader); diff --git a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs index c50de10658..1a2b13e946 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs @@ -97,6 +97,11 @@ namespace MediaBrowser.Providers.Music { case "artist-list": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subReader = reader.ReadSubtree()) { return ParseArtistList(subReader); @@ -136,6 +141,11 @@ namespace MediaBrowser.Providers.Music { case "artist": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } var mbzId = reader.GetAttribute("id"); using (var subReader = reader.ReadSubtree()) diff --git a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs index dc24e3484f..dd3bfb4f82 100644 --- a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs +++ b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs @@ -127,6 +127,11 @@ namespace MediaBrowser.Providers.People { case "Actor": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { var info = FetchImageInfoFromActorNode(personName, subtree); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs index 9951a2519c..e189c292c1 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs @@ -139,6 +139,11 @@ namespace MediaBrowser.Providers.TV { case "Banner": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { AddImage(subtree, list, seasonNumber); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs index 6d4be31aca..2595ad5858 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs @@ -126,6 +126,11 @@ namespace MediaBrowser.Providers.TV { case "Banner": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { AddImage(subtree, list); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 112b17f4e2..cc8a90fe38 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -314,6 +314,11 @@ namespace MediaBrowser.Providers.TV { case "Series": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { return FindSeriesId(subtree); @@ -559,6 +564,11 @@ namespace MediaBrowser.Providers.TV { case "Series": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { var searchResult = GetSeriesSearchResultFromSubTree(subtree, comparableName); @@ -799,6 +809,11 @@ namespace MediaBrowser.Providers.TV { case "Series": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { FetchDataFromSeriesNode(result, subtree, cancellationToken); @@ -808,6 +823,11 @@ namespace MediaBrowser.Providers.TV case "Episode": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { var date = GetFirstAiredDateFromEpisodeNode(subtree, cancellationToken); @@ -942,6 +962,11 @@ namespace MediaBrowser.Providers.TV { case "Actor": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { FetchDataFromActorNode(result, subtree); diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 4bee8c3ca9..dba6d96ac4 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -655,15 +655,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers case "actor": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - var person = GetPersonFromXmlNode(subtree); - - if (!string.IsNullOrWhiteSpace(person.Name)) + using (var subtree = reader.ReadSubtree()) { - itemResult.AddPerson(person); + var person = GetPersonFromXmlNode(subtree); + + if (!string.IsNullOrWhiteSpace(person.Name)) + { + itemResult.AddPerson(person); + } } } + else + { + reader.Read(); + } break; } @@ -831,9 +838,16 @@ namespace MediaBrowser.XbmcMetadata.Parsers case "fileinfo": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - FetchFromFileInfoNode(subtree, item); + using (var subtree = reader.ReadSubtree()) + { + FetchFromFileInfoNode(subtree, item); + } + } + else + { + reader.Read(); } break; } @@ -896,15 +910,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers case "resume": { - using (var subtree = reader.ReadSubtree()) + if (!reader.IsEmptyElement) { - if (!string.IsNullOrWhiteSpace(userDataUserId)) + using (var subtree = reader.ReadSubtree()) { - var userData = GetOrAdd(itemResult, userDataUserId); + if (!string.IsNullOrWhiteSpace(userDataUserId)) + { + var userData = GetOrAdd(itemResult, userDataUserId); - FetchFromResumeNode(subtree, item, userData); + FetchFromResumeNode(subtree, item, userData); + } } } + else + { + reader.Read(); + } break; } @@ -1006,6 +1027,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers { case "streamdetails": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { FetchFromStreamDetailsNode(subtree, item); @@ -1039,6 +1065,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers { case "video": { + if (reader.IsEmptyElement) + { + reader.Read(); + continue; + } using (var subtree = reader.ReadSubtree()) { FetchFromVideoNode(subtree, item);