mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-02 07:52:12 +02:00
remove HTML escaping from (easy)json encoder everywhere.
This commit is contained in:
18
envelopes.go
18
envelopes.go
@@ -91,7 +91,7 @@ func (v *EventEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v EventEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["EVENT",`)
|
||||
if v.SubscriptionID != nil {
|
||||
w.RawString(`"` + *v.SubscriptionID + `",`)
|
||||
@@ -128,7 +128,7 @@ func (v *ReqEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v ReqEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["REQ",`)
|
||||
w.RawString(`"` + v.SubscriptionID + `"`)
|
||||
for _, filter := range v.Filters {
|
||||
@@ -183,7 +183,7 @@ func (v *CountEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v CountEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["COUNT",`)
|
||||
w.RawString(`"` + v.SubscriptionID + `"`)
|
||||
if v.Count != nil {
|
||||
@@ -219,7 +219,7 @@ func (v *NoticeEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v NoticeEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["NOTICE",`)
|
||||
w.Raw(json.Marshal(string(v)))
|
||||
w.RawString(`]`)
|
||||
@@ -245,7 +245,7 @@ func (v *EOSEEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v EOSEEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["EOSE",`)
|
||||
w.Raw(json.Marshal(string(v)))
|
||||
w.RawString(`]`)
|
||||
@@ -273,7 +273,7 @@ func (v *CloseEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v CloseEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["CLOSE",`)
|
||||
w.Raw(json.Marshal(string(v)))
|
||||
w.RawString(`]`)
|
||||
@@ -304,7 +304,7 @@ func (v *ClosedEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v ClosedEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["CLOSED",`)
|
||||
w.Raw(json.Marshal(string(v.SubscriptionID)))
|
||||
w.RawString(`,`)
|
||||
@@ -339,7 +339,7 @@ func (v *OKEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v OKEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["OK",`)
|
||||
w.RawString(`"` + v.EventID + `",`)
|
||||
ok := "false"
|
||||
@@ -379,7 +379,7 @@ func (v *AuthEnvelope) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
func (v AuthEnvelope) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
w.RawString(`["AUTH",`)
|
||||
if v.Challenge != nil {
|
||||
w.Raw(json.Marshal(*v.Challenge))
|
||||
|
@@ -169,13 +169,14 @@ func easyjsonF642ad3eEncodeGithubComNbdWtfGoNostr(out *jwriter.Writer, in Event)
|
||||
|
||||
// MarshalJSON supports json.Marshaler interface
|
||||
func (v Event) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
easyjsonF642ad3eEncodeGithubComNbdWtfGoNostr(&w, v)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
|
||||
// MarshalEasyJSON supports easyjson.Marshaler interface
|
||||
func (v Event) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
w.NoEscapeHTML = true
|
||||
easyjsonF642ad3eEncodeGithubComNbdWtfGoNostr(w, v)
|
||||
}
|
||||
|
||||
|
@@ -288,13 +288,14 @@ func easyjson4d398eaaEncodeGithubComNbdWtfGoNostr(out *jwriter.Writer, in Filter
|
||||
|
||||
// MarshalJSON supports json.Marshaler interface
|
||||
func (v Filter) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
easyjson4d398eaaEncodeGithubComNbdWtfGoNostr(&w, v)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
|
||||
// MarshalEasyJSON supports easyjson.Marshaler interface
|
||||
func (v Filter) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
w.NoEscapeHTML = true
|
||||
easyjson4d398eaaEncodeGithubComNbdWtfGoNostr(w, v)
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ func (v OpenEnvelope) MarshalJSON() ([]byte, error) {
|
||||
res.WriteString(v.SubscriptionID)
|
||||
res.WriteString(`",`)
|
||||
|
||||
w := jwriter.Writer{}
|
||||
w := jwriter.Writer{NoEscapeHTML: true}
|
||||
v.Filter.MarshalEasyJSON(&w)
|
||||
w.Buffer.DumpTo(res)
|
||||
|
||||
|
Reference in New Issue
Block a user