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

Fix surrogate pair handling in CStringUtf8Encoding

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.13.2
    • Affects Version/s: 2.13.1
    • Component/s: BSON
    • None

      We are trying to use the following to search a text using Regex. Here is our code:

       

      string name = "jm😋"

      var queryExpr = new BsonRegularExpression(name);
      var filter = Builders<CurrentClass>.Filter.Regex(s => s.Name, queryExpr);

       

      Upon running this one, we will received an error showing: 
      Regular expression is invalid: invalid UTF-8 string

       

      We try to inspect the query that is being generated from that filter, and surprisingly it doesn't use the $regex syntax. Here is the generated query:
      find({ "Name" : /jm😋/ })

       

       

      We are expecting the $regex syntax like this one: 
      find({ "Name" :

      { "$regex" : "jm\ud83d\ude0b" }

      })

       

      This is a serious bug on the Regex Filter Builder on the c# Library. Is there a way to use the $regex filter in the Filter Builder strongly type? We want to avoid creating BSON document as possible since it is not strongly typed.

       

      Using latest version of the c# Library: 2.13.1

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            airwyntin@investagrams.com Air A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: