script: Ensure EventSource field value is ignored if the null character exists in the field name (#36854)

Spec has updated so that any null characters in the `id` field name
would result in the value being ignored.

Testing: Covered by
`tests/wpt/tests/eventsource/format-field-id-null.window.js`

Signed-off-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
Keith Yeung 2025-05-05 19:38:40 +08:00 committed by GitHub
parent 8608e328a1
commit b3980dc2ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 16 deletions

View file

@ -183,7 +183,9 @@ impl EventSourceContext {
self.data.push_str(&self.value);
self.data.push('\n');
},
"id" => mem::swap(&mut self.last_event_id, &mut self.value),
"id" if !self.value.contains('\0') => {
mem::swap(&mut self.last_event_id, &mut self.value);
},
"retry" => {
if let Ok(time) = u64::from_str(&self.value) {
self.event_source