ngx-sse-client icon indicating copy to clipboard operation
ngx-sse-client copied to clipboard

Field processing does not handle optional space character

Open paulkmoore opened this issue 1 year ago • 1 comments

Hi @rubinhos,

Firstly thanks for keeping this library going, I appreciate that maintaining such things takes effort.

I have discovered an issue in parseChunkLine which does not handle the optional space character in field lines. For context, please see the ABNF in the spec; specifically:

field = 1*name-char [ colon [ space ] *any-char ] end-of-line

Accordingly, when processing field lines that have the (optional) space character, this ends up being included in the field data i.e. given:

id: 1234

the event.id field contains " 1234", not "1234".

The spec is specific about this being a single optional space character, but I think in general any leading whitespace should be a candidate to be trimmed; thoughts?

I'm happy to fork and create a PR if that's helpful / appropriate?

Best, Paul

Debugger image for context, please see the rogue space character in the id field and o variable:

Screenshot 2023-05-10 at 10 13 57

paulkmoore avatar May 10 '23 10:05 paulkmoore