[CSHARP-1676] BsonDocument.Parse and multiple JSON values Created: 23/May/16 Updated: 19/Apr/18 Resolved: 25/May/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.2.4 |
| Fix Version/s: | 2.3 |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Wan Bachtiar | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Minor Change |
| Description |
|
BsonDocument.Parse() allows extra text after the first document, and ignores it. For example:
As observed, BsonDocument.Parse does not seem to complain that the second text is invalid, and ignored the rest. Although if the first document is invalid, it will throw FormatException , for example :
Only the first full document is read/validated. |
| Comments |
| Comment by Githook User [ 25/May/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Githook User [ 25/May/16 ] |
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |
| Comment by Robert Stam [ 24/May/16 ] |
|
Actually, it should make no difference whether the extra characters are valid JSON or not. We can argue that BsonDocument.Parse should check that it has consumed the entire string, and that ANY extra characters are an error. |