[JAVA-1793] JsonReader incorrectly parses strings containing Unicode surrogate pairs Created: 04/May/15  Updated: 05/May/15  Resolved: 04/May/15

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1, 3.1.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

First reported on mongodb-users.

JsonReader reads the full surrogate pair using String.codePointAt, but then always moves the position by one character.



 Comments   
Comment by Jeffrey Yemin [ 05/May/15 ]

Closed for 3.0.1 release.

Comment by Githook User [ 04/May/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Since JsonBuffer is reading character-by-character anyway, there is no need to use String.codePointAt. And doing so is incorrect
unless there is a corresponding call to Character.charCount instead of just incrementing the position by a single character. The fix
is simply to use use String.charAt instead of String.codePointAt.

JAVA-1793
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/49654cf31a77dbde8e1f06061808ec28f477fb18

Comment by Githook User [ 04/May/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Since JsonBuffer is reading character-by-character anyway, there is no need to use String.codePointAt. And doing so is incorrect
unless there is a corresponding call to Character.charCount instead of just incrementing the position by a single character. The fix
is simply to use use String.charAt instead of String.codePointAt.

JAVA-1793
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/ca5df77fa2c60760b5ef360335e5b6f58a3cbba0

Comment by William Delanoue [ 04/May/15 ]

Hi,

I correct it with a simple :

package org.bson.json;

class JsonBuffer {
public int read()

{ return (position >= buffer.length()) ? -1 : buffer.charAt(position++); }

(don't know if unread must be corrected to, I think so)

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