You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EventSource] Is Last-Event-ID header value allowed to contain any-char? #689
A Last-Event-ID header value is set to the last event ID string which can contain any chars except CR and LF. On the other hand, the Fetch spec requires that a header value consists of field-content octets. The former allows non-CRLF control octets while the latter doesn't.
When the ID contains "\f", the reconnection request contains a Last-Event-ID header with the received ID.
When the ID contains "\0", the reconnection request contains a Last-Event-ID header with a trimmed value (e.g. If "abc\0def" was received, "abc" will be sent).
Firefox:
When the ID contains "\f", the reconnection request contains a Last-Event-ID header with the received ID.
When the ID contains "\0", the reconnection request doesn't contain a Last-Event-ID header.
The EventSource spec allows any octet composing a valid utf-8 string other than \r and \n while the HTTP spec allows only us-ascii printable chars (VCHAR).
Both are acceptable, but I'm leaning towards ignoring an id field containing non-VCHARs. It looks consistent with the fact that we ignore an invalid retry field and other unrecognized fields.
@yutakahirano I think it would be even better if we didn't set evt.lastEventId at all if the id field contained U+0000. It does seem however that current implementation do include it and I also cannot reproduce your Chrome behavior (it does not appear to trim the value). See web-platform-tests/wpt#6584 for my test.
Activity
yutakahirano commentedon Feb 12, 2016
cc: @annevk
annevk commentedon Feb 12, 2016
See also whatwg/fetch#115. I'm happy to align this with whatever implementations implement. @hiroshige-g did not get back to me on that yet.
yutakahirano commentedon Feb 12, 2016
Chrome:
Firefox:
yutakahirano commentedon Feb 12, 2016
I would like to ignore an ID value including any control characters when parsing it.
annevk commentedon Mar 14, 2016
Control being anything less than 0x20 or higher than 0x7E?
annevk commentedon Mar 14, 2016
Ooh, seems like the specification allows for non-ASCII values.
yutakahirano commentedon Mar 15, 2016
The EventSource spec allows any octet composing a valid utf-8 string other than \r and \n while the HTTP spec allows only us-ascii printable chars (VCHAR).
annevk commentedon Mar 15, 2016
You preference would be that we require VCHAR in the specification instead and ignore anything outside?
annevk commentedon Mar 15, 2016
@wanderview, do you know who to ask from Mozilla about this?
yutakahirano commentedon Mar 17, 2016
Both are acceptable, but I'm leaning towards ignoring an id field containing non-VCHARs. It looks consistent with the fact that we ignore an invalid retry field and other unrecognized fields.
overholt commentedon Mar 28, 2016
@mcmanus can probably comment from Mozilla's standpoint.
annevk commentedon Jul 18, 2017
@yutakahirano given what we decided for https://fetch.spec.whatwg.org/#concept-header-value I think UTF-8 bytes except for 0x00, 0x0A, and 0x0D is the way to go. Let me know if you disagree.
yutakahirano commentedon Jul 18, 2017
Does it mean Firefox's behavior in #689 (comment)?
annevk commentedon Jul 18, 2017
Yeah, ignoring altogether if it doesn't meet the criteria seems best. Dropping part of the value seems more dangerous.
2 remaining items
annevk commentedon Jul 19, 2017
@yutakahirano I think it would be even better if we didn't set
evt.lastEventIdat all if the id field contained U+0000. It does seem however that current implementation do include it and I also cannot reproduce your Chrome behavior (it does not appear to trim the value). See web-platform-tests/wpt#6584 for my test.annevk commentedon Jul 19, 2017
(It's also odd that browsers do not have the U+0000 restriction on header values here while they do have that in other APIs...)
EventSource: ignore IDs with U+0000
annevk commentedon Jul 19, 2017
#2849 has my proposal for how to change the HTML Standard. It would require changes by all implementations though, so feedback appreciated.
EventSource: do not allow lastEventId creation when the id contains U…
EventSource: ignore IDs with U+0000
EventSource: do not allow lastEventId creation when the id contains U…
[EventSource] Fix null character handling for ID buffer
EventSource: do not allow lastEventId creation when the id contains U…
[EventSource] Fix null character handling for ID buffer
EventSource: ignore IDs with U+0000