From 5699fe470df543c800fa95fd67e815db8eff9c96 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Jun 2016 13:14:13 +0530 Subject: [PATCH] Changes for Ignoring Illegal character from xml (XMLTOJSON Utility) --- 350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility/Default.aspx.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility/Default.aspx.cs b/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility/Default.aspx.cs index 2cd6201..4cb3bc1 100644 --- a/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility/Default.aspx.cs +++ b/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility/Default.aspx.cs @@ -35,7 +35,11 @@ namespace XMLtoJSON_utility FileUploader.SaveAs(Server.MapPath(DefaultFileName) + FileUploader.FileName); string path = Server.MapPath("~/Upload/" + FileUploader.PostedFile.FileName); - doc.Load(path); + string encodedXml = System.Security.SecurityElement.Escape(path); + + StreamReader reader = new StreamReader(encodedXml, Encoding.ASCII); + + doc.Load(reader); txtXml.Text = doc.InnerXml; string JSON = XmlToJSON(doc); txtJson.Text = JSON; @@ -158,16 +162,16 @@ namespace XMLtoJSON_utility StringBuilder sbOut = new StringBuilder(sIn.Length); foreach (char ch in sIn) { - if (Char.IsControl(ch) || ch == '\'') - { - int ich = (int)ch; - sbOut.Append(@"\u" + ich.ToString("x4")); - continue; - } - else if (ch == '\"' || ch == '\\' || ch == '/') - { - sbOut.Append('\\'); - } + //if (Char.IsControl(ch) || ch == '\'') + //{ + // int ich = (int)ch; + // sbOut.Append(@"\u" + ich.ToString("x4")); + // continue; + //} + //else if (ch == '\"' || ch == '\\' || ch == '/') + //{ + // sbOut.Append('\\'); + //} sbOut.Append(ch); } return sbOut.ToString(); -- libgit2 0.21.4