[Mono-bugs] [Bug 543332] New: Roundtripping XmlReader.ReadElementContentAsBase64 and XmlWriter.WriteBase64 does not give identical results
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Sep 30 18:33:03 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=543332
Summary: Roundtripping XmlReader.ReadElementContentAsBase64 and
XmlWriter.WriteBase64 does not give identical results
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: x86-64
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.XML
AssignedTo: atsushi at ximian.com
ReportedBy: anton at lauridsen.info
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.14)
Gecko/2009090217 Ubuntu/9.04 (jaunty) Firefox/3.0.14
I would expect that "round-tripping" an array, by first writing to an Base64
element, and then reading the same element back, would produce output identical
to the input, but that turns out not to be consistently true.
Reproducible: Always
Steps to Reproduce:
1) define an array like this:
byte[] fakeState = new byte[1024];
for(int i = 0; i<fakeState.Length; i++)
fakeState[i] = (byte)(i & 0xff);
2) write the array using XmlWriter.WriteBase64, either to a string or a file
3) read the data back from xml, using code similar to this:
byte[] fixedSizeBuffer = new byte[1024];
// we cannot completely trust the length read
to indicate the end.
int bytesRead;
do
{
bytesRead =
reader.ReadElementContentAsBase64(fixedSizeBuffer, 0, 1024);
Console.WriteLine(bytesRead + " " +
reader.NodeType.ToString());
if(bytesRead > 0)
{
if(readDataBuffer == null)
readDataBuffer = new byte[0];
int oldLength = readDataBuffer.Length;
Array.Resize(ref readDataBuffer,
oldLength + bytesRead);
Array.Copy(fixedSizeBuffer, 0,
readDataBuffer, oldLength, bytesRead);
}
} while(bytesRead > 0 && reader.NodeType ==
XmlNodeType.Text);
produces an output array with 1026 elements, and output like this:
1024 Text
2 EndElement
I would have expected to see:
1024 Text
0 EndElement
and an array with a length of 1024.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list