diff --git a/config templates/config/feedProxy.config b/config templates/config/feedProxy.config
new file mode 100644
index 0000000000..c34fd48031
--- /dev/null
+++ b/config templates/config/feedProxy.config
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/umbraco.sln b/umbraco.sln
index 93bf2633f1..18ca4aca3a 100644
--- a/umbraco.sln
+++ b/umbraco.sln
@@ -38,6 +38,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{05329D
config templates\config\Dashboard.config = config templates\config\Dashboard.config
config templates\config\ExamineIndex.config = config templates\config\ExamineIndex.config
config templates\config\ExamineSettings.config = config templates\config\ExamineSettings.config
+ config templates\config\feedProxy.config = config templates\config\feedProxy.config
config templates\config\formHandlers.config = config templates\config\formHandlers.config
config templates\config\metablogConfig.config = config templates\config\metablogConfig.config
config templates\config\restExtensions.config = config templates\config\restExtensions.config
diff --git a/umbraco/businesslogic/IO/SystemFiles.cs b/umbraco/businesslogic/IO/SystemFiles.cs
index aa747f2459..b840511e4c 100644
--- a/umbraco/businesslogic/IO/SystemFiles.cs
+++ b/umbraco/businesslogic/IO/SystemFiles.cs
@@ -84,6 +84,14 @@ namespace umbraco.IO
}
}
+ public static string FeedProxyConfig
+ {
+ get
+ {
+ return string.Concat(SystemDirectories.Config, "/feedProxy.config");
+ }
+ }
+
public static string ContentCacheXml
{
get
diff --git a/umbraco/cms/businesslogic/Packager/PackageActions/StandardPackageActions.cs b/umbraco/cms/businesslogic/Packager/PackageActions/StandardPackageActions.cs
index 46e8b85d31..d77f2bfe26 100644
--- a/umbraco/cms/businesslogic/Packager/PackageActions/StandardPackageActions.cs
+++ b/umbraco/cms/businesslogic/Packager/PackageActions/StandardPackageActions.cs
@@ -520,6 +520,98 @@ namespace umbraco.cms.businesslogic.packager.standardPackageActions
}
+ public class addProxyFeedHost : umbraco.interfaces.IPackageAction
+ {
+ #region IPackageAction Members
+
+ public bool Execute(string packageName, XmlNode xmlData)
+ {
+ var hostname = xmlData.Attributes["host"].Value;
+ if (string.IsNullOrEmpty(hostname))
+ return false;
+
+ var xdoc = xmlHelper.OpenAsXmlDocument(SystemFiles.FeedProxyConfig);
+
+ xdoc.PreserveWhitespace = true;
+
+ var xn = xdoc.SelectSingleNode("//feedProxy");
+ if (xn != null)
+ {
+ var insert = true;
+
+ if (xn.HasChildNodes)
+ {
+ foreach (XmlNode node in xn.SelectNodes("//allow"))
+ {
+ if (node.Attributes["host"] != null && node.Attributes["host"].Value == hostname)
+ insert = false;
+ }
+ }
+
+ if (insert)
+ {
+ var newHostname = xmlHelper.addTextNode(xdoc, "allow", string.Empty);
+ newHostname.Attributes.Append(xmlHelper.addAttribute(xdoc, "host", hostname));
+ xn.AppendChild(newHostname);
+
+ xdoc.Save(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public string Alias()
+ {
+ return "addProxyFeedHost";
+ }
+
+ public bool Undo(string packageName, XmlNode xmlData)
+ {
+ var hostname = xmlData.Attributes["host"].Value;
+ if (string.IsNullOrEmpty(hostname))
+ return false;
+
+ var xdoc = xmlHelper.OpenAsXmlDocument(SystemFiles.FeedProxyConfig);
+ xdoc.PreserveWhitespace = true;
+
+ var xn = xdoc.SelectSingleNode("//feedProxy");
+ if (xn != null)
+ {
+ bool inserted = false;
+ if (xn.HasChildNodes)
+ {
+ foreach (XmlNode node in xn.SelectNodes("//allow"))
+ {
+ if (node.Attributes["host"] != null && node.Attributes["host"].Value == hostname)
+ {
+ xn.RemoveChild(node);
+ inserted = true;
+ }
+ }
+ }
+
+ if (inserted)
+ {
+ xdoc.Save(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ #endregion
+
+ public XmlNode SampleXml()
+ {
+ string sample = "";
+ return helper.parseStringToXmlNode(sample);
+ }
+ }
+
///
/// This class implements the IPackageAction Interface, used to execute code when packages are installed.
/// All IPackageActions only takes a PackageName and a XmlNode as input, and executes based on the data in the xmlnode.
diff --git a/umbraco/presentation/config/feedProxy.config b/umbraco/presentation/config/feedProxy.config
new file mode 100644
index 0000000000..c34fd48031
--- /dev/null
+++ b/umbraco/presentation/config/feedProxy.config
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj
index 724e44321e..905095835c 100644
--- a/umbraco/presentation/umbraco.presentation.csproj
+++ b/umbraco/presentation/umbraco.presentation.csproj
@@ -2572,6 +2572,7 @@
+
SettingsSingleFileGenerator
Settings1.Designer.cs
diff --git a/umbraco/presentation/umbraco/dashboard/FeedProxy.aspx.cs b/umbraco/presentation/umbraco/dashboard/FeedProxy.aspx.cs
index 7c45d95562..6952b81bda 100644
--- a/umbraco/presentation/umbraco/dashboard/FeedProxy.aspx.cs
+++ b/umbraco/presentation/umbraco/dashboard/FeedProxy.aspx.cs
@@ -1,37 +1,53 @@
namespace dashboardUtilities
{
using System;
- using System.Collections.Generic;
using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
using System.Net;
- using System.IO;
+ using System.Net.Mime;
+ using System.Xml;
using umbraco.BasePages;
+ using umbraco.BusinessLogic;
+ using umbraco.IO;
+ using umbraco;
public partial class FeedProxy : UmbracoEnsuredPage
{
protected void Page_Load(object sender, EventArgs e)
{
- if (Request["url"] != null)
+ try
{
- var requestUri = new Uri(Request["url"]);
- if (requestUri != null)
+ if (Request.QueryString.AllKeys.Contains("url") && Request.QueryString["url"] != null)
{
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
- request.Method = WebRequestMethods.Http.Get;
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader reader = new StreamReader(response.GetResponseStream());
- string tmp = reader.ReadToEnd();
- response.Close();
+ var url = Request.QueryString["url"];
+ if (!string.IsNullOrWhiteSpace(url) && !url.StartsWith("/"))
+ {
+ Uri requestUri;
+ if (Uri.TryCreate(url, UriKind.Absolute, out requestUri))
+ {
+ var feedProxyXml = xmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
+ if (feedProxyXml != null && feedProxyXml.SelectSingleNode(string.Concat("//access[@host = '", requestUri.Host, "']")) == null)
+ {
+ using (var client = new WebClient())
+ {
+ var response = client.DownloadString(requestUri);
- Response.Clear();
- Response.ContentType = "text/xml";
-
- Response.Write(tmp);
+ if (!string.IsNullOrEmpty(response))
+ {
+ Response.Clear();
+ Response.ContentType = Request.QueryString["type"] ?? MediaTypeNames.Text.Xml;
+ Response.Write(response);
+ Response.End();
+ }
+ }
+ }
+ }
+ }
}
}
+ catch (Exception ex)
+ {
+ Log.Add(LogTypes.Error, -1, ex.ToString());
+ }
}
}
}
\ No newline at end of file