diff --git a/src/Umbraco.Core/EntityExtensions.cs b/src/Umbraco.Core/EntityExtensions.cs
deleted file mode 100644
index e1eae64301..0000000000
--- a/src/Umbraco.Core/EntityExtensions.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.Linq;
-using Umbraco.Core.Models;
-
-namespace Umbraco.Core
-{
- public static class ContentBaseExtensions
- {
- public static void SanitizeEntityPropertiesForXmlStorage(this IContentBase entity)
- {
- entity.Name = entity.Name.ToValidXmlString();
- foreach (var property in entity.Properties)
- {
- if (property.Value is string)
- {
- var value = (string)property.Value;
- property.Value = value.ToValidXmlString();
- }
- }
- }
-
- public static void SanitizeTagsForXmlStorage(this ITag entity)
- {
- entity.Text = entity.Text.ToValidXmlString();
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs
index 768ae37c9b..dceed0e259 100644
--- a/src/Umbraco.Core/Models/ContentExtensions.cs
+++ b/src/Umbraco.Core/Models/ContentExtensions.cs
@@ -240,6 +240,28 @@ namespace Umbraco.Core.Models
return content.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Contains(recycleBinId.ToInvariantString());
}
+
+ ///
+ /// Removes characters that are not valide XML characters from all entity properties
+ /// of type string. See: http://stackoverflow.com/a/961504/5018
+ ///
+ ///
+ ///
+ /// If this is not done then the xml cache can get corrupt and it will throw YSODs upon reading it.
+ ///
+ ///
+ public static void SanitizeEntityPropertiesForXmlStorage(this IContentBase entity)
+ {
+ entity.Name = entity.Name.ToValidXmlString();
+ foreach (var property in entity.Properties)
+ {
+ if (property.Value is string)
+ {
+ var value = (string)property.Value;
+ property.Value = value.ToValidXmlString();
+ }
+ }
+ }
///
/// Checks if the IContentBase has children
@@ -734,10 +756,6 @@ namespace Umbraco.Core.Models
{
return ((PackagingService)(ApplicationContext.Current.Services.PackagingService)).Export(member);
}
-
#endregion
}
-
-
-
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/EntityExtensions.cs b/src/Umbraco.Core/Models/EntityExtensions.cs
index 6daf99a58d..9fbd4ce592 100644
--- a/src/Umbraco.Core/Models/EntityExtensions.cs
+++ b/src/Umbraco.Core/Models/EntityExtensions.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Linq;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
@@ -23,5 +20,5 @@ namespace Umbraco.Core.Models
var dirty = (IRememberBeingDirty)entity;
return dirty.WasPropertyDirty("Id");
}
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Repositories/TagsRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TagsRepository.cs
index 8e651fd614..1d687d1974 100644
--- a/src/Umbraco.Core/Persistence/Repositories/TagsRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/TagsRepository.cs
@@ -137,8 +137,6 @@ namespace Umbraco.Core.Persistence.Repositories
{
((Entity)entity).AddingEntity();
- entity.SanitizeTagsForXmlStorage();
-
var factory = new TagFactory();
var dto = factory.BuildDto(entity);
diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs
index 07378b98d8..10ba5fab32 100644
--- a/src/Umbraco.Core/StringExtensions.cs
+++ b/src/Umbraco.Core/StringExtensions.cs
@@ -1318,10 +1318,18 @@ namespace Umbraco.Core
@"(?
+ /// An extension method that returns a new string in which all occurrences of an
+ /// unicode characters that are invalid in XML files are replaced with an empty string.
+ ///
+ /// Current instance of the string
+ /// Updated string
+ ///
///
/// removes any unusual unicode characters that can't be encoded into XML
///
- public static string ToValidXmlString(this string text)
+ internal static string ToValidXmlString(this string text)
{
return string.IsNullOrEmpty(text) ? text : InvalidXmlChars.Replace(text, "");
}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 036719ef81..096ee04948 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -291,7 +291,6 @@
-