diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 27ade0f7b5..82500ae2d4 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -123,6 +123,18 @@ namespace Umbraco.Core } } + /// + /// The original/first url that the web application executes + /// + /// + /// we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must + /// exist on a global context because the keep alive service doesn't run in a web context. + /// we are NOT going to put a lock on this because locking will slow down the application and we don't really care + /// if two threads write to this at the exact same time during first page hit. + /// see: http://issues.umbraco.org/issue/U4-2059 + /// + internal string OriginalRequestUrl { get; set; } + private bool Configured { get @@ -163,7 +175,6 @@ namespace Umbraco.Core } } - private void AssertIsReady() { if (!this.IsReady) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 5d38c0527a..97567ca29c 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -278,6 +278,14 @@ default.aspx + ASPXCodeBehind + + + noNodes.aspx + ASPXCodeBehind + + + noNodes.aspx ASPXCodeBehind diff --git a/src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.cs b/src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.cs new file mode 100644 index 0000000000..503c53a9f3 --- /dev/null +++ b/src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.WebPages; + +namespace Umbraco.Web.UI.Config.Splashes +{ + public partial class NoNodes : System.Web.UI.Page + { + + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + + var store = UmbracoContext.Current.RoutingContext.PublishedContentStore; + if (store.HasContent(UmbracoContext.Current)) + { + //if there is actually content, go to the root + Response.Redirect("~/"); + } + } + + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.designer.cs b/src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.designer.cs similarity index 64% rename from src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.designer.cs rename to src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.designer.cs index d14ea3a40c..0063e40629 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.designer.cs +++ b/src/Umbraco.Web.UI/config/splashes/NoNodes.aspx.designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // @@ -7,18 +7,18 @@ // //------------------------------------------------------------------------------ -namespace umbraco.presentation.channels { +namespace Umbraco.Web.UI.Config.Splashes { - public partial class wlwmanifest { + public partial class NoNodes { /// - /// xhtml control. + /// Form1 control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Literal xhtml; + protected global::System.Web.UI.HtmlControls.HtmlForm Form1; } } diff --git a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx index 84c0befdc6..01b1505b43 100644 --- a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx +++ b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx @@ -1,183 +1,149 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> +<%@ Page Language="C#" AutoEventWireup="True" Inherits="Umbraco.Web.UI.Config.Splashes.NoNodes" CodeBehind="NoNodes.aspx.cs" %> <%@ Import Namespace="Umbraco.Core.Configuration" %> +<%@ Import Namespace="Umbraco.Core.IO" %> - - - Umbraco - <%=UmbracoVersion.Current.ToString(3)%> - - no pages found + + Umbraco - no pages found " /> - + - + - + - - - + + + - - - - - - + +
- + -
+
-
+
- + - - - - -
- - - - - -
- - + + - +
+
+

Looks like there's still work to do

+

+ You're seeing the wonderful page because your website doesn't contain any published content yet. +

+

+ So get rid of this page by starting umbraco and publishing some content. You can do this by clicking the "set up your new website" button below. +

+ +
+
+
+   +
+
+
-
-
-
- - - - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
- -
- + + + + + + + + +
+ + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Umbraco.Web.UI/umbraco/channels/rsd.aspx b/src/Umbraco.Web.UI/umbraco/channels/rsd.aspx index 20ec1882e8..98f32ff992 100644 --- a/src/Umbraco.Web.UI/umbraco/channels/rsd.aspx +++ b/src/Umbraco.Web.UI/umbraco/channels/rsd.aspx @@ -1,11 +1,20 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rsd.aspx.cs" Inherits="umbraco.presentation.umbraco.channels.rsd" %> + +<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> +<%@ Import Namespace="Umbraco.Core.IO" %> + + umbraco http://umbraco.org/ http://<%=Request.ServerVariables["SERVER_NAME"]%> - <%=umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/channels.aspx" /> - <%=umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/channels.aspx" /> + <%=IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/channels.aspx" /> + <%=IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/channels.aspx" /> - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/channels/wlwmanifest.aspx b/src/Umbraco.Web.UI/umbraco/channels/wlwmanifest.aspx index c14d5fa55d..9f4d7a135b 100644 --- a/src/Umbraco.Web.UI/umbraco/channels/wlwmanifest.aspx +++ b/src/Umbraco.Web.UI/umbraco/channels/wlwmanifest.aspx @@ -1,11 +1,33 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wlwmanifest.aspx.cs" Inherits="umbraco.presentation.channels.wlwmanifest" %> + +<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> +<%@ Import Namespace="Umbraco.Core.IO" %> +<%@ Import Namespace="umbraco" %> + + http://umbraco.org/images/liveWriterIcon.png http://umbraco.org/images/liveWriterWatermark.png View your site/weblog Edit your site/weblog - {blog-homepage-url}<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/ - {blog-homepage-url}<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/actions/editContent.aspx?id={post-id} + {blog-homepage-url}<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/ + {blog-homepage-url}<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco)%>/actions/editContent.aspx?id={post-id} @@ -25,4 +47,5 @@ Yes Yes - \ No newline at end of file + + diff --git a/src/Umbraco.Web.UI/umbraco/settings/modals/ShowUmbracoTags.aspx b/src/Umbraco.Web.UI/umbraco/settings/modals/ShowUmbracoTags.aspx index ffa0426ec6..9663dc6e15 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/modals/ShowUmbracoTags.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/modals/ShowUmbracoTags.aspx @@ -1,6 +1,7 @@ <%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Title="ShowUmbracoTags" Codebehind="ShowUmbracoTags.aspx.cs" AutoEventWireup="True" Inherits="umbraco.cms.presentation.settings.modal.ShowUmbracoTags" %> +<%@ Import Namespace="Umbraco.Core.IO" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> @@ -44,9 +45,9 @@ MetaBlogApi / Content Channels - <link rel="EditURI" type="application/rsd+xml" href="http://<%=Request.ServerVariables["SERVER_NAME"] %><%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/channels/rsd.aspx" /> + <link rel="EditURI" type="application/rsd+xml" href="http://<%=Request.ServerVariables["SERVER_NAME"] %><%= IOHelper.ResolveUrl(SystemDirectories.Umbraco)%>/channels/rsd.aspx" />

- <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://<%=Request.ServerVariables["SERVER_NAME"] %><%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/channels/wlwmanifest.aspx" /> + <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://<%=Request.ServerVariables["SERVER_NAME"] %><%= IOHelper.ResolveUrl(SystemDirectories.Umbraco)%>/channels/wlwmanifest.aspx" />
Insert the above two elements to the head element to gain optimal support for diff --git a/src/Umbraco.Web/LegacyScheduledTasks.cs b/src/Umbraco.Web/LegacyScheduledTasks.cs index ca819e02ed..8b4ccce8e9 100644 --- a/src/Umbraco.Web/LegacyScheduledTasks.cs +++ b/src/Umbraco.Web/LegacyScheduledTasks.cs @@ -34,10 +34,10 @@ namespace Umbraco.Web // of course we should have a proper scheduler, see #U4-809 // ping/keepalive - _pingTimer = new Timer(new TimerCallback(global::umbraco.presentation.keepAliveService.PingUmbraco), umbracoApplication.Context, 60000, 300000); + _pingTimer = new Timer(new TimerCallback(global::umbraco.presentation.keepAliveService.PingUmbraco), applicationContext, 60000, 300000); // (un)publishing _and_ also run scheduled tasks (!) - _publishingTimer = new Timer(new TimerCallback(global::umbraco.presentation.publishingService.CheckPublishing), umbracoApplication.Context, 30000, 60000); + _publishingTimer = new Timer(new TimerCallback(global::umbraco.presentation.publishingService.CheckPublishing), applicationContext, 30000, 60000); // log scrubbing AddTask(LOG_SCRUBBER_TASK_NAME, GetLogScrubbingInterval()); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4b789ec9a6..1672a78861 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -471,8 +471,14 @@ + ASPXCodeBehind + + ASPXCodeBehind + + ASPXCodeBehind + ASPXCodeBehind @@ -720,21 +726,7 @@ - - ASPXCodeBehind - rsd.aspx - - - rsd.aspx - - - ASPXCodeBehind - wlwmanifest.aspx - - - wlwmanifest.aspx - @@ -1844,8 +1836,6 @@ - - @@ -1973,7 +1963,9 @@ ASPXCodeBehind - + + ASPXCodeBehind + ASPXCodeBehind diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index 36adfdcb29..e2b136f535 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Web; using System.Web.Routing; using Umbraco.Core; +using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Web.Routing; using umbraco; -using umbraco.IO; using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings; using UmbracoSettings = Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Web.Configuration; @@ -30,6 +30,16 @@ namespace Umbraco.Web /// void BeginRequest(HttpContextBase httpContext) { + //we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must + //exist on a global context because the keep alive service doesn't run in a web context. + //we are NOT going to put a lock on this because locking will slow down the application and we don't really care + //if two threads write to this at the exact same time during first page hit. + //see: http://issues.umbraco.org/issue/U4-2059 + if (ApplicationContext.Current.OriginalRequestUrl.IsNullOrWhiteSpace()) + { + ApplicationContext.Current.OriginalRequestUrl = string.Format("{0}:{1}{2}", httpContext.Request.ServerVariables["SERVER_NAME"], httpContext.Request.ServerVariables["SERVER_PORT"], IOHelper.ResolveUrl(SystemDirectories.Umbraco)); + } + // do not process if client-side request if (IsClientSideRequest(httpContext.Request.Url)) return; diff --git a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs index 44cca4e7e4..4ab1646a9e 100644 --- a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs +++ b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs @@ -2,29 +2,35 @@ using System; using System.Diagnostics; using System.Net; using System.Web; +using Umbraco.Core; +using Umbraco.Core.Logging; namespace umbraco.presentation { /// - /// Summary description for keepAliveService. + /// Makes a call to /umbraco/ping.aspx which is used to keep the web app alive /// public class keepAliveService { + //NOTE: sender will be the umbraco ApplicationContext public static void PingUmbraco(object sender) { - if (sender == null) + if (sender == null || !(sender is ApplicationContext)) return; - string url = string.Format("http://{0}/ping.aspx", ((HttpContext)sender).Application["umbracoUrl"]); + + var appContext = (ApplicationContext) sender; + + var url = string.Format("http://{0}/ping.aspx", appContext.OriginalRequestUrl); try { - using (WebClient wc = new WebClient()) + using (var wc = new WebClient()) { wc.DownloadString(url); } } catch(Exception ee) { - Debug.Write(string.Format("Error in ping({0}) -> {1}", url, ee)); + LogHelper.Debug(string.Format("Error in ping({0}) -> {1}", url, ee)); } } } diff --git a/src/Umbraco.Web/umbraco.presentation/publishingService.cs b/src/Umbraco.Web/umbraco.presentation/publishingService.cs index cf537da504..d22165d648 100644 --- a/src/Umbraco.Web/umbraco.presentation/publishingService.cs +++ b/src/Umbraco.Web/umbraco.presentation/publishingService.cs @@ -18,6 +18,7 @@ namespace umbraco.presentation private static readonly Hashtable ScheduledTaskTimes = new Hashtable(); private static bool _isPublishingRunning = false; + //NOTE: sender will be the umbraco ApplicationContext public static void CheckPublishing(object sender) { if(_isPublishingRunning) @@ -112,7 +113,7 @@ namespace umbraco.presentation private static bool getTaskByHttp(string url) { - HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); + var myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse myHttpWebResponse = null; try { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx deleted file mode 100644 index 20ec1882e8..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx +++ /dev/null @@ -1,11 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rsd.aspx.cs" Inherits="umbraco.presentation.umbraco.channels.rsd" %> - - umbraco - http://umbraco.org/ - http://<%=Request.ServerVariables["SERVER_NAME"]%> - - <%=umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/channels.aspx" /> - <%=umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/channels.aspx" /> - - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs index 59ab1ad046..7686a48738 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using System.Configuration; using System.Collections; @@ -11,6 +11,7 @@ using System.Web.UI.HtmlControls; namespace umbraco.presentation.umbraco.channels { + [Obsolete("This class is no longer used and will be removed from the codebase in future versions")] public partial class rsd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.designer.cs deleted file mode 100644 index 857c10d11a..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.designer.cs +++ /dev/null @@ -1,15 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.presentation.umbraco.channels { - - - public partial class rsd { - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx deleted file mode 100644 index c14d5fa55d..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx +++ /dev/null @@ -1,28 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wlwmanifest.aspx.cs" Inherits="umbraco.presentation.channels.wlwmanifest" %> - - http://umbraco.org/images/liveWriterIcon.png - http://umbraco.org/images/liveWriterWatermark.png - View your site/weblog - Edit your site/weblog - {blog-homepage-url}<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/ - {blog-homepage-url}<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco)%>/actions/editContent.aspx?id={post-id} - - - - WebLayout - - - Yes - Yes - Yes - No - 100 - Yes - Yes - No - No - No - Yes - Yes - - \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs index f71178bceb..51b7b38335 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using System.Configuration; using System.Collections; @@ -11,16 +11,29 @@ using System.Web.UI.HtmlControls; namespace umbraco.presentation.channels { + [Obsolete("This class is no longer used and will be removed from the codebase in future versions")] public partial class wlwmanifest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { bool useXhtml = false; - if (bool.TryParse(GlobalSettings.EditXhtmlMode, out useXhtml) && !useXhtml) { + if (bool.TryParse(GlobalSettings.EditXhtmlMode, out useXhtml) && !useXhtml) + { xhtml.Text = "no"; - } else { + } + else + { xhtml.Text = "yes"; } } + + /// + /// xhtml control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal xhtml; } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/ping.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/ping.aspx.cs index 56a2d66646..758c602942 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/ping.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/ping.aspx.cs @@ -11,16 +11,10 @@ using System.Web.UI.HtmlControls; namespace umbraco.presentation { - /// - /// Summary description for ping. - /// + [Obsolete("This class is no longer used and will be removed in future versions.")] public partial class ping : System.Web.UI.Page { - protected void Page_Load(object sender, System.EventArgs e) - { - } - #region Web Form Designer generated code override protected void OnInit(EventArgs e) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs index 1ffdf75020..478c1bdea7 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertChar.aspx.cs @@ -6,7 +6,7 @@ using System.Web.UI.WebControls; namespace umbraco.presentation.umbraco.plugins.tinymce3 { - public partial class insertChar : System.Web.UI.Page + public partial class insertChar : BasePages.UmbracoEnsuredPage { protected override void OnLoad(EventArgs e) { diff --git a/src/umbraco.businesslogic/BasePages/BasePage.cs b/src/umbraco.businesslogic/BasePages/BasePage.cs index 81076120d6..ad7d73ddb8 100644 --- a/src/umbraco.businesslogic/BasePages/BasePage.cs +++ b/src/umbraco.businesslogic/BasePages/BasePage.cs @@ -6,12 +6,12 @@ using System.Web.Mvc; using System.Web.Routing; using System.Web.Security; using Umbraco.Core; +using Umbraco.Core.IO; using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Services; using umbraco.BusinessLogic; using umbraco.DataLayer; -using umbraco.IO; using System.Web.UI; namespace umbraco.BasePages diff --git a/src/umbraco.cms/helpers/url.cs b/src/umbraco.cms/helpers/url.cs index 1bd2efd682..e32b0333f4 100644 --- a/src/umbraco.cms/helpers/url.cs +++ b/src/umbraco.cms/helpers/url.cs @@ -1,8 +1,8 @@ using System; using System.Xml; using System.Text.RegularExpressions; -using umbraco.IO; using Umbraco.Core; +using Umbraco.Core.IO; using Umbraco.Core.CodeAnnotations; namespace umbraco.cms.helpers @@ -33,12 +33,17 @@ namespace umbraco.cms.helpers /// True if it's an allowed url public static bool ValidateProxyUrl(string url, string callerUrl) { + if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute)) + { + return false; + } + Uri requestUri; - Uri localUri; if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out requestUri)) { - if (!String.IsNullOrEmpty(callerUrl)) + if (!string.IsNullOrEmpty(callerUrl)) { + Uri localUri; if (Uri.TryCreate(callerUrl, UriKind.RelativeOrAbsolute, out localUri)) { // check for local urls @@ -49,18 +54,21 @@ namespace umbraco.cms.helpers } else { + //TODO: SD: why throw an exception?? shouldn't we just return false ? throw new ArgumentException("CallerUrl is in a wrong format that couldn't be parsed as a valid URI. If you don't want to evaluate for local urls, but just proxy urls then leave callerUrl empty", "callerUrl"); } } // check for valid proxy urls - var feedProxyXml = xmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig)); + var feedProxyXml = XmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig)); if (feedProxyXml != null && feedProxyXml.SelectSingleNode(string.Concat("//allow[@host = '", requestUri.Host, "']")) != null) { return true; } - } else + } + else { + //TODO: SD: why throw an exception?? shouldn't we just return false ? throw new ArgumentException("url is in a wrong format that couldn't be parsed as a valid URI", "url"); }