[GODRIVER-473] toExtJSON does not escape double quotes in strings Created: 20/Jun/18 Updated: 28/Oct/23 Resolved: 25/Oct/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | JSON & ExtJSON |
| Affects Version/s: | None |
| Fix Version/s: | 0.0.17 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Gregoire Pean | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I am pulling entries from a collection, and converting each to JSON. The JSON which is generated is not always "legal": the mongo go driver does not seem to escape quotes in value strings, so the generated JSON is not compliant. This seems like a pretty serious bug - Am I doing anything wrong? Relevant code pasted below.
|
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 25/Oct/18 ] | ||||||||||||
|
Hi gpean, I'm moving this to closed. If you are still having this issue, please comment on this ticket or open a new one. Thanks, Kris | ||||||||||||
| Comment by Kristofer Brandow (Inactive) [ 19/Oct/18 ] | ||||||||||||
|
Hi gpean, We have implemented a new extended JSON encoder and decoder. Can you update your code and see if escaping is working properly for you? Thanks, Kris | ||||||||||||
| Comment by Ayush Gupta [X] [ 11/Aug/18 ] | ||||||||||||
|
Maybe we can do:
If it works? | ||||||||||||
| Comment by Gregoire Pean [ 27/Jun/18 ] | ||||||||||||
|
Updated https://github.com/mongodb/mongo-go-driver/pull/70/commits/9b87979bcb0773023f6cad069c369b7e6478c08e | ||||||||||||
| Comment by Gregoire Pean [ 27/Jun/18 ] | ||||||||||||
|
Good point! | ||||||||||||
| Comment by Юрий Соколов [ 27/Jun/18 ] | ||||||||||||
|
I think, it is still not valid JSON escaping. http://www.ietf.org/rfc/rfc4627.txt > All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F). | ||||||||||||
| Comment by Gregoire Pean [ 20/Jun/18 ] | ||||||||||||
| Comment by Gregoire Pean [ 20/Jun/18 ] | ||||||||||||
|
Working patch:
| ||||||||||||
| Comment by Gregoire Pean [ 20/Jun/18 ] | ||||||||||||
|
Looking at the driver code below it seems we simplistically append strings without any attempt at escaping?
|