From 857d72530c3ec05f034ad8ea88faf8a89b7850e9 Mon Sep 17 00:00:00 2001 From: JamesNK Date: Wed, 1 Jun 2011 07:12:46 +0000 Subject: [PATCH] -Change reading schema references to ignore additional content after the $ref property --- Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs | 2 +- Src/Newtonsoft.Json/Properties/AssemblyInfo.cs | 2 +- Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index d26198c2..96fae985 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -41,5 +41,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly: AssemblyVersion("4.0.2.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.0.2.13728")] +[assembly: AssemblyFileVersion("4.0.2.13801")] #endif diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index 9712e8bc..4a96e921 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -110,7 +110,7 @@ using System.Security; // by using the '*' as shown below: [assembly: AssemblyVersion("4.0.2.0")] #if !PocketPC -[assembly: AssemblyFileVersion("4.0.2.13728")] +[assembly: AssemblyFileVersion("4.0.2.13801")] #endif [assembly: CLSCompliant(true)] diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs index 830adbe8..7a140d6e 100644 --- a/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs +++ b/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs @@ -97,7 +97,15 @@ namespace Newtonsoft.Json.Schema if (propertyName == JsonSchemaConstants.ReferencePropertyName) { string id = (string)_reader.Value; - _reader.Read(); + + // skip to the end of the current object + while (_reader.Read() && _reader.TokenType != JsonToken.EndObject) + { + if (_reader.TokenType == JsonToken.StartObject) + throw new Exception("Found StartObject within the schema reference with the Id '{0}'" + .FormatWith(CultureInfo.InvariantCulture, id)); + } + JsonSchema referencedSchema = _resolver.GetSchema(id); if (referencedSchema == null) throw new Exception("Could not resolve schema reference for Id '{0}'.".FormatWith(CultureInfo.InvariantCulture, id));