HTTP 400 response with body "URI Error: URI malformed" when requesting an URL with a ISO-8859-1 encoding
When requesting an URL with ISO-8859-1 enconding the server fails with HTTP 400 (bad request) and the following body:
URIError: URI malformed
URL : /index.html?param=%DANICO
%DANICO is ÚNICO URL enconded using ISO-8859-1
ecstatic, the web server under the hood of http-server, uses decodeURI, which decodes characters by their UTF-8 sequence, not by ISO-8859-1.
Weird stuff I noticed:
- I get
GET /U%CC%81NICO/in the logs when requesting/ÚNICOin my browser. encodeURIComponent('ÚNICO')gives me%C3%9ANICO.
Since this issue was opened, we've internalized what ecstatic provided and removed the dependency, so we have more control over this. However, I'm not sure how to approach this, would we want some way to detect or configure what URL encoding to use? Or maybe if UTF-8 decoding fails, we try ISO-8859-1 and see if that works?