From a69a80e8e8cb780201522ec58f9679063d9b25d0 Mon Sep 17 00:00:00 2001 From: Scott Ferugson Date: Fri, 3 Oct 2025 15:14:19 -0400 Subject: [PATCH] Fix Incorrect Xml Read Deserializing a Byte Array Change from using ReadString() to ReadElementString() when deserialization a byte array. The expectation ToByteArrayHex() and ToByteArrayBase64() is that the XmlDocument will be left at the start of next Xml element. But with just a ReadString() the document is left at the end tag of the current element, not the start of the next element. Changing to ReadElementString() changes this behavior. --- .../System.Xml.Serialization/XmlSerializationReader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs index de6710af0a5f..3d6da9b0b151 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs @@ -853,11 +853,11 @@ protected byte[] ToByteArrayBase64 (bool isNull) { readCount++; if (isNull) { - Reader.ReadString (); + Reader.ReadElementString (); return null; } else - return ToByteArrayBase64 (Reader.ReadString ()); + return ToByteArrayBase64 (Reader.ReadElementString ()); } protected static byte[] ToByteArrayBase64 (string value) @@ -869,11 +869,11 @@ protected byte[] ToByteArrayHex (bool isNull) { readCount++; if (isNull) { - Reader.ReadString (); + Reader.ReadElementString (); return null; } else - return ToByteArrayHex (Reader.ReadString ()); + return ToByteArrayHex (Reader.ReadElementString ()); } protected static byte[] ToByteArrayHex (string value)