diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index 0c9226cf02..31b13056ca 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -1329,11 +1329,13 @@ namespace MediaBrowser.LocalMetadata.Parsers protected Share GetShare(XmlReader reader) { - reader.MoveToContent(); - var item = new Share(); - while (reader.Read()) + reader.MoveToContent(); + reader.Read(); + + // Loop through each element + while (!reader.EOF) { if (reader.NodeType == XmlNodeType.Element) { @@ -1350,12 +1352,17 @@ namespace MediaBrowser.LocalMetadata.Parsers item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase); break; } - default: - reader.Skip(); - break; + { + reader.Skip(); + break; + } } } + else + { + reader.Read(); + } } // This is valid diff --git a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs index d792373bf1..c42b44f9e5 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs @@ -31,11 +31,13 @@ namespace MediaBrowser.LocalMetadata.Parsers private void FetchFromCollectionItemsNode(XmlReader reader, MetadataResult item) { - reader.MoveToContent(); - var list = new List(); - while (reader.Read()) + reader.MoveToContent(); + reader.Read(); + + // Loop through each element + while (!reader.EOF) { if (reader.NodeType == XmlNodeType.Element) { @@ -55,12 +57,17 @@ namespace MediaBrowser.LocalMetadata.Parsers break; } - default: - reader.Skip(); - break; + { + reader.Skip(); + break; + } } } + else + { + reader.Read(); + } } item.Item.LinkedChildren = list; diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs index 4c45545fce..ee986ae2df 100644 --- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs @@ -65,11 +65,13 @@ namespace MediaBrowser.LocalMetadata.Parsers private void FetchFromCollectionItemsNode(XmlReader reader, Playlist item) { - reader.MoveToContent(); - var list = new List(); - while (reader.Read()) + reader.MoveToContent(); + reader.Read(); + + // Loop through each element + while (!reader.EOF) { if (reader.NodeType == XmlNodeType.Element) { @@ -89,12 +91,17 @@ namespace MediaBrowser.LocalMetadata.Parsers break; } - default: - reader.Skip(); - break; + { + reader.Skip(); + break; + } } } + else + { + reader.Read(); + } } item.LinkedChildren = list; @@ -102,11 +109,13 @@ namespace MediaBrowser.LocalMetadata.Parsers private void FetchFromSharesNode(XmlReader reader, Playlist item) { - reader.MoveToContent(); - var list = new List(); - while (reader.Read()) + reader.MoveToContent(); + reader.Read(); + + // Loop through each element + while (!reader.EOF) { if (reader.NodeType == XmlNodeType.Element) { @@ -126,12 +135,17 @@ namespace MediaBrowser.LocalMetadata.Parsers break; } - default: - reader.Skip(); - break; + { + reader.Skip(); + break; + } } } + else + { + reader.Read(); + } } item.Shares = list; diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 74a9680625..3c1bc21183 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -513,9 +513,10 @@ namespace MediaBrowser.Providers.TV using (var reader = XmlReader.Create(streamReader, settings)) { reader.MoveToContent(); + reader.Read(); // Loop through each element - while (reader.Read()) + while (!reader.EOF) { if (reader.NodeType == XmlNodeType.Element) { @@ -546,12 +547,17 @@ namespace MediaBrowser.Providers.TV break; } - default: - reader.Skip(); - break; + { + reader.Skip(); + break; + } } } + else + { + reader.Read(); + } } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index 649fec824e..5bbcc9d157 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -82,67 +82,73 @@ namespace MediaBrowser.Providers.TV // Use XmlReader for best performance using (reader) { - reader.MoveToContent(); - - // Loop through each element - while (reader.Read()) - { - cancellationToken.ThrowIfCancellationRequested(); - - if (reader.NodeType == XmlNodeType.Element) - { - switch (reader.Name) - { - case "thumb_width": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) - { - width = rval; - } - } - break; - } - - case "thumb_height": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) - { - height = rval; - } - } - break; - } - - case "filename": - { - var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) - { - url = TVUtils.BannerUrl + val; - } - break; - } - - default: - reader.Skip(); - break; - } - } - } + reader.MoveToContent(); + reader.Read(); + + // Loop through each element + while (!reader.EOF) + { + if (reader.NodeType == XmlNodeType.Element) + { + cancellationToken.ThrowIfCancellationRequested(); + + switch (reader.Name) + { + case "thumb_width": + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + int rval; + + // int.TryParse is local aware, so it can be probamatic, force us culture + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + { + width = rval; + } + } + break; + } + + case "thumb_height": + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + int rval; + + // int.TryParse is local aware, so it can be probamatic, force us culture + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + { + height = rval; + } + } + break; + } + + case "filename": + { + var val = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(val)) + { + url = TVUtils.BannerUrl + val; + } + break; + } + default: + { + reader.Skip(); + break; + } + } + } + else + { + reader.Read(); + } + } } if (string.IsNullOrEmpty(url))