From 5c1fa0cf9cbe4301082b6cad343d42ef4c414c0d Mon Sep 17 00:00:00 2001 From: ud2 Date: Mon, 25 Mar 2024 22:31:13 +0800 Subject: fix(ext/fetch): do not truncate field value in `EventSource` (#22368) Depends on #22493. Closes #22367. --- ext/fetch/27_eventsource.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ext/fetch') diff --git a/ext/fetch/27_eventsource.js b/ext/fetch/27_eventsource.js index 02b77e88d..1ab9d8009 100644 --- a/ext/fetch/27_eventsource.js +++ b/ext/fetch/27_eventsource.js @@ -15,7 +15,6 @@ const { StringPrototypeIncludes, StringPrototypeIndexOf, StringPrototypeSlice, - StringPrototypeSplit, StringPrototypeStartsWith, StringPrototypeToLowerCase, SymbolFor, @@ -268,8 +267,10 @@ class EventSource extends EventTarget { } else { let field = chunk; let value = ""; - if (StringPrototypeIncludes(chunk, ":")) { - ({ 0: field, 1: value } = StringPrototypeSplit(chunk, ":")); + const colonIndex = StringPrototypeIndexOf(chunk, ":"); + if (colonIndex !== -1) { + field = StringPrototypeSlice(chunk, 0, colonIndex); + value = StringPrototypeSlice(chunk, colonIndex + 1); if (StringPrototypeStartsWith(value, " ")) { value = StringPrototypeSlice(value, 1); } -- cgit v1.2.3