|
} |
|
OpCode::Text => { |
|
if frame.fin && !frame.is_utf8() { |
|
(Err(WebSocketError::InvalidUTF8), None) |
A single utf-8 character may contain multiple bytes and fragmentation may lead to the last segment having partial utf-8.
rfc 6455 has already suggested this.
I can guess that this is relatively unlikely to happen, fragmentation of a text segment from the middle of a non ascii character, but is not impossible. Specially if the text contains 4-byte emojis or is a non English text.