From fe645c5cad1e76991357dc554b02c510547b0bd6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 9 Apr 2013 12:42:55 -0400 Subject: [PATCH] centralize page size value --- MediaBrowser.Controller/Library/DtoBuilder.cs | 8 ++---- .../HttpServer/HttpServer.cs | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Controller/Library/DtoBuilder.cs b/MediaBrowser.Controller/Library/DtoBuilder.cs index d54563e41b..c1f0ccc0f3 100644 --- a/MediaBrowser.Controller/Library/DtoBuilder.cs +++ b/MediaBrowser.Controller/Library/DtoBuilder.cs @@ -836,17 +836,13 @@ namespace MediaBrowser.Controller.Library BaseItem item = null; - if (userId.HasValue) - { - item = libraryManager.GetItemById(new Guid(id)); - } - else if (!isIndexFolder) + if (!isIndexFolder) { item = libraryManager.GetItemById(new Guid(id)); } // If we still don't find it, look within individual user views - if (item == null && !userId.HasValue) + if (item == null && !userId.HasValue && isIndexFolder) { foreach (var user in userManager.Users) { diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index c2a936f1c9..2eea8ff754 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The name of the server. private string ServerName { get; set; } - private ContainerAdapter _containerAdapter; + private readonly ContainerAdapter _containerAdapter; /// /// Initializes a new instance of the class. @@ -149,7 +149,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (!string.IsNullOrEmpty(exception.Message)) { - res.AddHeader("X-Application-Error-Code", exception.Message.Replace(Environment.NewLine, " ")); + var error = exception.Message.Replace(Environment.NewLine, " "); + error = RemoveControlCharacters(error); + + res.AddHeader("X-Application-Error-Code", error); } } @@ -188,6 +191,27 @@ namespace MediaBrowser.Server.Implementations.HttpServer }); } + /// + /// Removes the control characters. + /// + /// The in string. + /// System.String. + private static string RemoveControlCharacters(string inString) + { + if (inString == null) return null; + + var newString = new StringBuilder(); + + foreach (var ch in inString) + { + if (!char.IsControl(ch)) + { + newString.Append(ch); + } + } + return newString.ToString(); + } + /// /// Starts the Web Service ///