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 44 "bytes"
55 "strconv"
66 "strings"
7+ "unicode"
78)
89
910// Event holds the structured data for an event.
@@ -120,7 +121,16 @@ func (e *Event) Write(p []byte) (int, error) {
120121
121122// WriteString adds string data to the event.
122123// Equivalent to calling Write([]byte(string))
124+ // Panics if provided with non-ascii input
123125func (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+ }
124134 // split event on newlines
125135 split := strings .Split (p , "\n " )
126136 for _ , entry := range split {
You can’t perform that action at this time.
0 commit comments