You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should add support for an exception to the text() method. The text() method converts the bytes to UTF-8 using UTF-8 decode. If the UTF-8 byte sequence is malformed, then the text() method should throw an exception.
The text was updated successfully, but these errors were encountered:
We depend on the UTF-8 decode operation defined in the Encoding spec. The default error mode for decoders is defined to be replacement instead of fatal, which means we shouldn't throw. Replacement characters will be inserted instead.
Is my reading correct, @annevk? That matches at least Chrome's implementation.
Would we want to explicitly override the error mode? I'm inclined not to, since our closest sibling method on Bodydoesn't either.
Yeah, we generally don't do that in the platform. Are the raw bytes exposed somewhere? If they are you can already get this kind of error handling if you want by using a TextDecoder object.
self.addEventListener('push',event=>{constdecoder=newTextDecoder('utf-8',{fatal: true});try{decoder.decode(event.data.arrayBuffer());}catch(e){/* do something with |e| */}});
Let me close this based on prior art and the availability of a way to get the exceptions if necessary. Happy to reconsider if you disagree!
https://www.w3.org/TR/push-api/#pushmessagedata-interface
You should add support for an exception to the text() method. The text() method converts the bytes to UTF-8 using UTF-8 decode. If the UTF-8 byte sequence is malformed, then the text() method should throw an exception.
The text was updated successfully, but these errors were encountered: