diff --git a/src/Umbraco.Core/Macros/MacroTagParser.cs b/src/Umbraco.Core/Macros/MacroTagParser.cs
index 236a184cc0..94eb6a69bc 100644
--- a/src/Umbraco.Core/Macros/MacroTagParser.cs
+++ b/src/Umbraco.Core/Macros/MacroTagParser.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
+using HtmlAgilityPack;
namespace Umbraco.Core.Macros
{
@@ -10,7 +11,7 @@ namespace Umbraco.Core.Macros
///
internal class MacroTagParser
{
- private static readonly Regex MacroRteContent = new Regex(@"(
.*?)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
private static readonly Regex MacroPersistedFormat = new Regex(@"(<\?UMBRACO_MACRO macroAlias=[""'](\w+?)[""'].+?)(?:/>|>.*?\?UMBRACO_MACRO>)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
///
@@ -88,7 +89,33 @@ namespace Umbraco.Core.Macros
///
internal static string FormatRichTextContentForPersistence(string rteContent)
{
- return MacroRteContent.Replace(rteContent, match =>
+ if (string.IsNullOrEmpty(rteContent))
+ {
+ return string.Empty;
+ }
+
+ var html = new HtmlDocument();
+ html.LoadHtml(rteContent);
+
+ //get all the comment nodes we want
+ var commentNodes = html.DocumentNode.SelectNodes("//comment()[contains(., ' with the comment node itself.
+ foreach (var c in commentNodes)
+ {
+ var div = c.ParentNode;
+ var divContainer = div.ParentNode;
+ divContainer.ReplaceChild(c, div);
+ }
+
+ var parsed = html.DocumentNode.OuterHtml;
+
+ //now replace all the with nothing
+ return MacroRteContent.Replace(parsed, match =>
{
if (match.Groups.Count >= 3)
{
@@ -96,7 +123,7 @@ namespace Umbraco.Core.Macros
return match.Groups[2].Value;
}
//replace with nothing if we couldn't find the syntax for whatever reason
- return "";
+ return string.Empty;
});
}
diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs
index 22d8f5bb5c..d3305af031 100644
--- a/src/Umbraco.Core/PluginManager.cs
+++ b/src/Umbraco.Core/PluginManager.cs
@@ -459,24 +459,24 @@ namespace Umbraco.Core
private readonly HashSet _types = new HashSet();
private IEnumerable _assemblies;
-
///
- /// Returns all found property editors
+ /// Returns all found property editors (based on the resolved Iparameter editors - this saves a scan)
///
internal IEnumerable ResolvePropertyEditors()
{
//return all proeprty editor types found except for the base property editor type
- return ResolveTypes().ToArray()
- .Except(new[] {typeof (PropertyEditor)});
+ return ResolveTypes()
+ .Where(x => x.IsType())
+ .Except(new[] { typeof(PropertyEditor) });
}
///
- /// Returns all found parameter editors
+ /// Returns all found parameter editors (which includes property editors)
///
internal IEnumerable ResolveParameterEditors()
{
//return all paramter editor types found except for the base property editor type
- return ResolveTypes().ToArray()
+ return ResolveTypes()
.Except(new[] { typeof(ParameterEditor), typeof(PropertyEditor) });
}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 3aa3a3d5bc..880673ef6e 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -44,6 +44,9 @@
..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll
+
+ ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll
+
False
..\packages\log4net-mediumtrust.2.0.0\lib\log4net.dll
diff --git a/src/Umbraco.Core/packages.config b/src/Umbraco.Core/packages.config
index 7ad8fc5ac1..cc673f88a1 100644
--- a/src/Umbraco.Core/packages.config
+++ b/src/Umbraco.Core/packages.config
@@ -1,6 +1,7 @@
+
diff --git a/src/Umbraco.Tests/Macros/MacroParserTests.cs b/src/Umbraco.Tests/Macros/MacroParserTests.cs
index 56fc4f2062..78dd51e855 100644
--- a/src/Umbraco.Tests/Macros/MacroParserTests.cs
+++ b/src/Umbraco.Tests/Macros/MacroParserTests.cs
@@ -158,5 +158,22 @@ asdfsdf