-Added IgnoreSerializableInterface to DefaultContractResolver

-Changed serializing ISerializable types under partial trust to error to fix security issue
-Fixed LinqBridge collision error in .NET 2.0 by moving types to a different namespace
-Fixed JObject.Keys error when object has no items
This commit is contained in:
James Newton-King
2012-03-18 16:24:30 +13:00
parent 9c7fb730f2
commit 8471c4ffe1
162 changed files with 3550 additions and 3566 deletions
@@ -31,11 +31,15 @@ using System.Collections.ObjectModel;
using System.Dynamic;
#endif
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities;
#if NET20
using Newtonsoft.Json.Utilities.LinqBridge;
#else
using System.Linq;
#endif
namespace Newtonsoft.Json.Serialization
{
@@ -825,6 +829,12 @@ To force JSON arrays to deserialize add the JsonArrayAttribute to the type.".For
{
Type objectType = contract.UnderlyingType;
if (!JsonTypeReflector.FullyTrusted)
{
throw new JsonSerializationException(@"Type '{0}' implements ISerializable but cannot be deserialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data.
To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add to JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true.".FormatWith(CultureInfo.InvariantCulture, objectType));
}
SerializationInfo serializationInfo = new SerializationInfo(contract.UnderlyingType, GetFormatterConverter());
bool exit = false;