Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 0c1f9d2

Browse files
committed
Handle unicode oddities in JSON marshaling
1 parent 6f303c2 commit 0c1f9d2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

manifest.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package main
66

77
import (
8+
"bytes"
89
"encoding/json"
910
"fmt"
1011
"io"
@@ -117,7 +118,16 @@ func (m *manifest) MarshalJSON() ([]byte, error) {
117118
raw.Overrides[string(n)] = toPossible(pp)
118119
}
119120

120-
return json.Marshal(raw)
121+
b, err := json.Marshal(raw)
122+
if err != nil {
123+
return nil, err
124+
}
125+
126+
// Semver range ops, > and <, get turned into unicode code points. This is a
127+
// nice example of why using JSON for files like this is not the best
128+
b = bytes.Replace(b, []byte("\\u003c"), []byte("<"), -1)
129+
b = bytes.Replace(b, []byte("\\u003e"), []byte(">"), -1)
130+
return b, nil
121131
}
122132

123133
func toPossible(pp gps.ProjectProperties) (p possibleProps) {

0 commit comments

Comments
 (0)