#19052: Fixing encoding issues with shape tracing

Work Item: 19052

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-09-27 17:06:13 -07:00
parent c95b408d68
commit f55f87ba14
2 changed files with 8 additions and 3 deletions

View File

@@ -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) {

View File

@@ -60,8 +60,8 @@ shapeTracingMetadataHost[@Model.ShapeId].shape = {
</text>
}
],
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)) }
};