File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 4
4
"bytes"
5
5
"strconv"
6
6
"strings"
7
+ "unicode"
7
8
)
8
9
9
10
// Event holds the structured data for an event.
@@ -120,7 +121,16 @@ func (e *Event) Write(p []byte) (int, error) {
120
121
121
122
// WriteString adds string data to the event.
122
123
// Equivalent to calling Write([]byte(string))
124
+ // Panics if provided with non-ascii input
123
125
func (e * Event ) WriteString (p string ) {
126
+ // check ASCII
127
+ for _ , c := range p {
128
+ if c > unicode .MaxASCII {
129
+ // TODO at next major version bump, convert this to return an error
130
+ // instead of a blind panic
131
+ panic ("eventsource: WriteString: Attempt to write non-ascii string" )
132
+ }
133
+ }
124
134
// split event on newlines
125
135
split := strings .Split (p , "\n " )
126
136
for _ , entry := range split {
You can’t perform that action at this time.
0 commit comments