Browse Source
Replace silent .replace() sanitization in format_sse_event() with explicit ValueError raises for \n, \r, and \0 in the event and id fields. Previously, format_sse_event() would strip those characters, creating a behavioral inconsistency with ServerSentEvent's AfterValidator which raises on the same input. As YuriiMotov pointed out: data allows newlines by SSE spec design (each line becomes a separate data: frame), but event and id are single-token fields where a newline is always a protocol violation. Silent stripping masks bugs at the call site; raising surfaces them where they belong. Both code paths now fail identically for the same invalid input. Tests updated from strip-behavior assertions to ValueError assertions, plus two new null-byte tests covering format_sse_event() directly for event and id.pull/15187/head
2 changed files with 34 additions and 18 deletions
Loading…
Reference in new issue