[JAVA-2450] JsonReader in unable to read all base64 characters when creating BinData Created: 16/Feb/17  Updated: 09/Mar/17  Resolved: 09/Mar/17

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: 3.0.0
Fix Version/s: 3.5.0

Type: Bug Priority: Minor - P4
Reporter: Dawid Kublik Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Issue

Currently *org.bson.json.JsonReader *in unable to read all base64 characters when creating BinData
Troublesome characters:* '+', '/', '='*

This makes for example org.bson.Document.parse(final String json) fail when reading documents with binary uuids.

To reproduce:

*in org.bson.json.JsonReaderTest.testBinDataWithNew() *
replace
`String json = "

{ \"a\" : new BinData(3, AQID) }

";`

with
`String json = "

{ \"a\" : new BinData(3, AQIDBA==) }

";`

to get new byte[]

{1, 2, 3, 4}

it will fail as BinDataConstructor expects only unquotted string as byte value and
org.bson.json.JsonScanner.scanUnquotedString()
reads only '$', '_', letters and digits



 Comments   
Comment by Githook User [ 09/Mar/17 ]

Author:

{u'username': u'dkublik', u'name': u'dkublik', u'email': u'dkublik@gmail.com'}

Message: JAVA-2450: In JsonReader allow quoted strings in BinData constructor
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e53fb26fb9733c12f9e0844c2fcf2d0c28185873

Comment by Jeffrey Yemin [ 16/Feb/17 ]

Thanks for the report. We'll take a look at your PR and merge it as soon as we can.

Comment by Dawid Kublik [ 16/Feb/17 ]

PR with possibile solution
https://github.com/mongodb/mongo-java-driver/pull/392

Generated at Thu Feb 08 08:57:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.