w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
336 stars 35 forks source link

Throw explicit error when setting invalid header in network commands #707

Closed juliandescottes closed 1 month ago

juliandescottes commented 1 month ago

For the headers parameter of the network.continueRequest command, we are not validating that the header names and values will lead to valid headers.

A header is defined in fetch as

A header is a tuple that consists of a name (a header name) and value (a header value). A header name is a byte sequence that matches the field-name token production. A header value is a byte sequence that matches the following conditions:

So in theory when we deserialize a header, we should fail if the provided value does not correspond to this definition.

We should probably handle the validation upfront so that the deserialization can no longer fail. When we encounter an invalid header we could either throw an invalid argument error, or come up with a new invalid header error, which could be useful for Puppeteer, which is explicitly checking for such errors in the implementation.