Verify that a string is valid utf-8 after encoding

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • 12_01_17
    • Affects Version/s: 1.10.1
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      It's possible to insert non valid utf-8 encoded strings into a collection. The driver needs to check after #force_encoding that the encoding is indeed valid.

      For example:

      1.9.3-p545 :006 > string = "\xED\xAE\xBA\xED\xB6\x86"
       => "\xED\xAE\xBA\xED\xB6\x86" 
      1.9.3-p545 :007 > string.encoding
       => #<Encoding:UTF-8> 
      1.9.3-p545 :008 > string.valid_encoding?
       => false 
      1.9.3-p545 :009 > coll.insert({"not-valid" => string})
       => BSON::ObjectId('5399da013005c8cf8a000001') 
      1.9.3-p545 :016 > coll.find().to_a.first["not-valid"].valid_encoding?
       => false 
      

            Assignee:
            Emily Stolfo (Inactive)
            Reporter:
            Emily Stolfo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: