[JAVA-3982] Tighten validation of $uuid values in extended JSON Created: 03/Feb/21  Updated: 28/Oct/23  Resolved: 05/Feb/21

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: None
Fix Version/s: 4.3.0

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

Backwards Compatibility: Minor Change
Documentation Changes: Not Needed

 Description   

JsonReader uses UUID.fromString to parse values in $uuid extended JSON, e.g.

{"_id" : { "$uuid" : "73ffd264-44b3-4c69-90e8-e7d1dfc035d4" }}

However, UUID.fromString is more permissive in its parsing than what is strictly allowed by the grammar documented in UUID.toString. In particular, it doesn't require that the hypens appear in the write place. The result is that two otherwise identical strings that differ only in hyphen placement will parse to different and unequal UUID values.

In scope of JAVA-3959, a spec test is being added for this case, and without tightening up the JsonReader parsing code, the driver fails the test.



 Comments   
Comment by Githook User [ 05/Feb/21 ]

Author:

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

Message: Tighten up parsing code for $uuid values in extended JSON (#658)

JAVA-3982
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f0439b5fe9c3bfa7ca2bb1f31e8d3c5b73be10b0

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