Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.7.0
-
Security Level: Public
-
None
-
CBG Sprint 75
-
3
Description
Need to ensure strings are correctly escaped when manually building JSON responses (we do this for some small efficiency reasons). We already do this in some places via ConvertToJSONString, need to make sure this is used comprehensively.
Same general issue as CBG-661, but that fix was too narrow.
E.g:
from handler.writeRawJSON, handler.writeRawJSONStatus
h.writeRawJSON([]byte(`{"id":"` + docid + `","ok":true,"rev":"` + newRev + `"}`)) |
h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":"`+docid+`","ok":true,"rev":"`+newRev+`"}`)) |
Attachments
Issue Links
- relates to
-
CBG-661 Errors from REST API produce invalid JSON
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
Need to ensure strings are correctly escaped when manually building JSON responses (we do this for some small efficiency reasons). We already do this in some places via ConvertToJSONString, need to make sure this is used comprehensively.
We can use the Go JSON Marshaller to get properly escaped JSON strings, and should still be cheaper than using the JSON marshaller on the entire struct. E.g: from handler.writeRawJSON, handler.writeRawJSONStatus {code:java} h.writeRawJSON([]byte(`{"id":"` + docid + `","ok":true,"rev":"` + newRev + `"}`)) {code} {code:java} h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":"`+docid+`","ok":true,"rev":"`+newRev+`"}`)) {code} |
Need to ensure strings are correctly escaped when manually building JSON responses (we do this for some small efficiency reasons). We already do this in some places via ConvertToJSONString, need to make sure this is used comprehensively.
E.g: from handler.writeRawJSON, handler.writeRawJSONStatus {code:java}h.writeRawJSON([]byte(`{"id":"` + docid + `","ok":true,"rev":"` + newRev + `"}`)) {code} {code:java}h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":"`+docid+`","ok":true,"rev":"`+newRev+`"}`)) {code} |
Description |
Need to ensure strings are correctly escaped when manually building JSON responses (we do this for some small efficiency reasons). We already do this in some places via ConvertToJSONString, need to make sure this is used comprehensively.
E.g: from handler.writeRawJSON, handler.writeRawJSONStatus {code:java}h.writeRawJSON([]byte(`{"id":"` + docid + `","ok":true,"rev":"` + newRev + `"}`)) {code} {code:java}h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":"`+docid+`","ok":true,"rev":"`+newRev+`"}`)) {code} |
Need to ensure strings are correctly escaped when manually building JSON responses (we do this for some small efficiency reasons). We already do this in some places via ConvertToJSONString, need to make sure this is used comprehensively.
Same general issue as E.g: from handler.writeRawJSON, handler.writeRawJSONStatus {code:java}h.writeRawJSON([]byte(`{"id":"` + docid + `","ok":true,"rev":"` + newRev + `"}`)) {code} {code:java}h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":"`+docid+`","ok":true,"rev":"`+newRev+`"}`)) {code} |
Priority | Major [ 3 ] | Critical [ 2 ] |
Assignee | The One [ the one ] | Isaac Lambat [ JIRAUSER25602 ] |
Story Points | 2 | 3 |
Sprint | CBG Sprint 75 [ 1625 ] |
Rank | Ranked lower |
Rank | Ranked higher |
Status | Open [ 1 ] | In Progress [ 3 ] |

Status | In Progress [ 3 ] | In Review [ 10107 ] |

Resolution | Fixed [ 1 ] | |
Status | In Review [ 10107 ] | Resolved [ 5 ] |
Status | Resolved [ 5 ] | Closed [ 6 ] |
Build sync_gateway-3.0.0-216 contains sync_gateway commit 51c3631 with commit message:
CBG-1412- JSON strings in some responses not being correctly escaped (#5023)