From 81a99d6f7dd893d09ea1556419279b97483a3bbd Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 28 Jan 2016 10:19:51 +0100 Subject: [PATCH] adds null check and ensures that SetInternalRedirectPublishedContent cannot be called with a null result --- src/Umbraco.Web/Routing/PublishedContentRequest.cs | 3 ++- src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/Routing/PublishedContentRequest.cs b/src/Umbraco.Web/Routing/PublishedContentRequest.cs index 78f4449c88..02ffc475d3 100644 --- a/src/Umbraco.Web/Routing/PublishedContentRequest.cs +++ b/src/Umbraco.Web/Routing/PublishedContentRequest.cs @@ -166,7 +166,8 @@ namespace Umbraco.Web.Routing /// preserve or reset the template, if any. public void SetInternalRedirectPublishedContent(IPublishedContent content) { - EnsureWriteable(); + if (content == null) throw new ArgumentNullException("content"); + EnsureWriteable(); // unless a template has been set already by the finder, // template should be null at that point. diff --git a/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs b/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs index 65371ecba4..2e075d8ed1 100644 --- a/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs +++ b/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs @@ -515,11 +515,11 @@ namespace Umbraco.Web.Routing { // redirect to another page var node = _routingContext.UmbracoContext.ContentCache.GetById(internalRedirectId); - - _pcr.SetInternalRedirectPublishedContent(node); // don't use .PublishedContent here + if (node != null) { - redirect = true; + _pcr.SetInternalRedirectPublishedContent(node); // don't use .PublishedContent here + redirect = true; ProfilingLogger.Logger.Debug("{0}Redirecting to id={1}", () => tracePrefix, () => internalRedirectId); } else