[SERVER-12756] Mongo shell not handling \u0000 correctly Created: 17/Feb/14  Updated: 05/Feb/16  Resolved: 05/Feb/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Charlie Page Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-6646 Strings with NUL bytes don't round-tr... Closed
Operating System: ALL
Participants:

 Description   

The drivers allow null to be inserted into strings for values. The shell doesn't properly interpret the value and truncates at the null for strings.

This creates problems with values inserted by the java driver for instance that are then examined in the shell.

mongos> db.test.insert({_id:'y\u0000z'})
mongos> db.test.insert({_id:'y\u0000a'})
mongos> db.test.find()
{ "_id" : "y" }
{ "_id" : "y" }

It's extremely confusing to users to see unique indexes apparently not operating as such. Not to mention inserting these documents into another collection is also not possible using the shell as they have the "same" unique index value.



 Comments   
Comment by Max Hirschhorn [ 05/Feb/16 ]
Behavior in 2.4.0-rc2

MongoDB shell version: 2.4.0-rc2
> db.test.find()
{ "_id" : "y" }
{ "_id" : "y" }

Behavior in 2.5.0

MongoDB shell version: 2.5.0
> db.test.find()
{ "_id" : "y\u0000z" }
{ "_id" : "y\u0000a" }

Behavior in 2.4.14 (SERVER-6646 wasn't actually backported)

MongoDB shell version: 2.4.14
> db.test.find()
{ "_id" : "y" }
{ "_id" : "y" }

Behavior in 2.6.11

MongoDB shell version: 2.6.11
> db.test.find()
{ "_id" : "y\u0000z" }
{ "_id" : "y\u0000a" }

Behavior in 3.0.9

MongoDB shell version: 3.0.9
> db.test.find()
{ "_id" : "y\u0000z" }
{ "_id" : "y\u0000a" }

Behavior in 3.2.1

MongoDB shell version: 3.2.1
> db.test.find()
{ "_id" : "y\u0000z" }
{ "_id" : "y\u0000a" }

Generated at Thu Feb 08 03:29:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.