-Fix ReadAsBytes for empty strings

-Fix (hopefully) signing merged assemblies
This commit is contained in:
JamesNK
2010-04-20 07:51:33 +00:00
parent 2f11d3f970
commit 7085a4915f
5 changed files with 60 additions and 5 deletions
+10 -2
View File
@@ -337,8 +337,16 @@ namespace Newtonsoft.Json
case '\'':
ReadStringIntoBuffer(currentChar);
byte[] data = Convert.FromBase64CharArray(_buffer.GetInternalBuffer(), 0, _buffer.Position);
_buffer.Position = 0;
byte[] data;
if (_buffer.Position == 0)
{
data = new byte[0];
}
else
{
data = Convert.FromBase64CharArray(_buffer.GetInternalBuffer(), 0, _buffer.Position);
_buffer.Position = 0;
}
SetToken(JsonToken.Bytes, data);
+2 -1
View File
@@ -41,7 +41,8 @@ namespace Newtonsoft.Json.Linq
// attempt to convert possible base 64 string to bytes
if (TokenType == JsonToken.String)
{
byte[] data = Convert.FromBase64String((string)Value);
string s = (string) Value;
byte[] data = (s.Length == 0) ? new byte[0] : Convert.FromBase64String(s);
SetToken(JsonToken.Bytes, data);
}