Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-930

If any of the keys in a Dictionary contains a null character serialization fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      Windows
    • Backwards Compatibility:
      Fully Compatible

      Description

      I came across the following error when I tried to serialize one of our documents. We submit exception documents with our product. So the following document came from a security scan of some kind.. Anyways mongo blew up and we caught the exception. We have a few hundred reports of this.

      The value trying to be inserted is "\u0000\"><script>alert(309)</script>"

      System.ArgumentException : Element names cannot contain nulls.
      Parameter name: name
      at MongoDB.Bson.IO.BsonWriter.WriteName(String name) in BsonWriter.cs: line 506
      at MongoDB.Bson.Serialization.Serializers.DictionarySerializer`2.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options) in DictionaryGenericSerializer.cs: line 194
      at MongoDB.Bson.Serialization.BsonClassMapSerializer.SerializeMember(BsonWriter bsonWriter, Object obj, BsonMemberMap memberMap) in BsonClassMapSerializer.cs: line 692
      at MongoDB.Bson.Serialization.BsonClassMapSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options) in BsonClassMapSerializer.cs: line 432
      at MongoDB.Bson.Serialization.BsonSerializer.Serialize(BsonWriter bsonWriter, Type nominalType, Object value, IBsonSerializationOptions options) in BsonSerializer.cs: line 805
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, IBsonSerializationOptions options, JsonWriterSettings settings) in BsonExtensionMethods.cs: line 304
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType, JsonWriterSettings settings) in BsonExtensionMethods.cs: line 319
      at MongoDB.Bson.BsonExtensionMethods.ToJson(Object obj, Type nominalType) in BsonExtensionMethods.cs: line 271
      at MongoDB.Bson.BsonExtensionMethods.ToJson(TNominalType obj) in BsonExtensionMethods.cs: line 220

        Attachments

          Activity

            People

            Assignee:
            rstam Robert Stam
            Reporter:
            bniemyjski Blake Niemyjski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: