diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs index 730690920..6569193ef 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs @@ -12,6 +12,7 @@ using Orchard.Security; using Orchard.Themes; using Orchard.UI; using Orchard.UI.Admin; +using System.Web; namespace Orchard.DesignerTools.Services { [OrchardFeature("Orchard.DesignerTools")] @@ -203,8 +204,12 @@ namespace Orchard.DesignerTools.Services { } public static string FormatJsonValue(string value) { + if(String.IsNullOrEmpty(value)) { + return String.Empty; + } + // replace " by \" in json strings - return value.Replace(@"\", @"\\").Replace("\"", @"\""").Replace("\r\n", @"\n").Replace("\r", @"\n").Replace("\n", @"\n"); + return HttpUtility.HtmlEncode(value).Replace(@"\", @"\\").Replace("\"", @"\""").Replace("\r\n", @"\n").Replace("\r", @"\n").Replace("\n", @"\n"); } private static string FormatShapeFilename(string shape, string shapeType, string displayType, string themePrefix, string extension) { diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml b/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml index 87bcf05d5..35fd81c30 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml @@ -60,8 +60,8 @@ shapeTracingMetadataHost[@Model.ShapeId].shape = { } ], - html: '@ShapeTracingFactory.FormatJsonValue(RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString())))', - templateContent: '@(ShapeTracingFactory.FormatJsonValue(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.").ToString() : (string)Model.TemplateContent))', + html: '@Html.Raw(ShapeTracingFactory.FormatJsonValue(RemoveEmptyLines(RemoveBeacons(Display(Model.ChildContent).ToString()))))', + templateContent: '@Html.Raw(ShapeTracingFactory.FormatJsonValue(String.IsNullOrWhiteSpace((string)Model.TemplateContent) ? @T("Content not available as coming from source code.").ToString() : (string)Model.TemplateContent))', model: { @(new MvcHtmlString((string)@Model.Dump)) } };