tim-smart / multipasta

MIT License
2 stars 1 forks source link

Text decoding being done too early. #23

Closed thynson closed 10 months ago

thynson commented 10 months ago

https://github.com/tim-smart/multipasta/blob/451de6a06ee4b1d05b5b6903e84ce97b0a277a19/src/internal/headers.ts#L88

Text decoding should only be done when the whole buffer of key or value was available, so multi-byte character that being splitted into different chunks can be properly decoded.

tim-smart commented 10 months ago

Good catch, will take a look at your PR when I have some time.

tim-smart commented 10 months ago

Actually this is ok, as header names (not values) can only contain A-Z, a-z, 0–9, hyphen ( - ), or underscore ( _ )

thynson commented 10 months ago

Yeah, I didn't read the spec seriously, but for key decoding it has been ensured at the first time that each byte must be a 7bit ASCII at the first time. For only value decoding it should be done in this way.