-Change reading schema references to ignore additional content after the $ref property

This commit is contained in:
JamesNK
2011-06-01 07:12:46 +00:00
parent 3997b601ff
commit 857d72530c
3 changed files with 11 additions and 3 deletions
@@ -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
@@ -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)]
@@ -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));