[SERVER-8542] Delete character is allowed by JSON to BSON parser Created: 12/Feb/13  Updated: 25/Jan/24  Resolved: 25/Apr/13

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

Type: Bug Priority: Minor - P4
Reporter: Andrew Emil (Inactive) Assignee: Andrew Emil (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Steps To Reproduce:

add the following test to jsontests.cpp

class QuotedFieldName7 : public Bad {
virtual string json() const {
return "

{ \"del\\u007Fdel\" : \"b\" }

";
}
};

and the output is

JsonTests::FromJsonTests::QuotedFieldName7 Expected expression fromjson( json() ) to throw MsgAssertionException but it threw nothing. @src/mongo/dbtests/jsontests.cpp:447

Participants:

 Comments   
Comment by Andrew Emil (Inactive) [ 23/Apr/13 ]

To echo what Tad said, this is handled identically in all places in the code, so it seems like it is not a bug.

$ echo "{\"del\u007Fdel del\":1}" | ./mongoimport -c ccc -d test
$ ./mongoexport -d test -c ccc
connected to: 127.0.0.1
{ "_id" : { "$oid" : "5176edcc03259780a574cd79" }, "deldel del" : 1 }
exported 1 records
$ ./mongo
> x = db.ccc.findOne()
> > for (k in x) { print("-----"); for(i=0;i<k.length;i++) { print("char is " + k.charCodeAt(i)) } }
-----
char is 95
char is 105
char is 100
-----
char is 100
char is 101
char is 108
char is 127
char is 100
char is 101
char is 108
char is 32
char is 100
char is 101
char is 108

So, seems like this is not a problem at all, it goes round-trip in the same way using all json parsers we have.

Comment by Tad Marshall [ 13/Feb/13 ]

The V8 JavaScript engine seems to think that DEL in a fieldname is OK:

> var c = { "del\u007fdel" : 1 }
> c
{ "del del" : 1 }
> for (k in c) { for (i=0;i<k.length;++i){print("char is " + k.charCodeAt(i))} }
char is 100
char is 101
char is 108
char is 127
char is 100
char is 101
char is 108
>

I'm not sure that this is a bug.

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