Skip to content

Commit 9af7c4c

Browse files
Turn off CheckCharacters to allow reading xml files with characters as [\u000b]. (#530)
1 parent 93a074d commit 9af7c4c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dotnet/src/dotnetframework/GxClasses/Helpers/XMLHelper.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ public static T Deserialize<T>(Type TargetType, string serialized, string sName,
8282
{
8383
using (StringReader sr = new StringReader(serialized))
8484
{
85-
deserialized = (T)(xmls.Deserialize(sr));
85+
using (XmlReader xmlReader = XmlReader.Create(sr, new XmlReaderSettings {CheckCharacters=false }))
86+
{
87+
deserialized = (T)(xmls.Deserialize(xmlReader));
88+
}
8689
}
8790
}
8891
catch (InvalidOperationException ex)
@@ -163,13 +166,14 @@ internal static string Serialize(string rootName, string sNameSpace, XmlAttribut
163166
string s;
164167
using (MemoryStream stream = new MemoryStream())
165168
{
166-
XmlWriter xmlw = XmlWriter.Create(stream, new System.Xml.XmlWriterSettings()
169+
XmlWriter xmlw = XmlWriter.Create(stream, new XmlWriterSettings()
167170
{
168171
OmitXmlDeclaration = !includeHeader,
169172
Indent = indentElements,
170173
IndentChars = "\t",
171-
Encoding = Encoding.UTF8
172-
});
174+
Encoding = Encoding.UTF8,
175+
CheckCharacters = false
176+
});
173177
XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
174178
xmlns.Add(string.Empty, sNameSpace);
175179
xmls.Serialize(xmlw, instance, xmlns);

0 commit comments

Comments
 (0)