Dear maintainer,
The bug here is kinda specific and weird, but a test-case is attached. I
apollogise if I don't use the latest version. But this bug has been
there for a while, and it's unlikely to fix itself.
Here is the setup:
- The server send a html content with the header:
Content-Type: text/html
- No encoding specified in the Content-Type header
- This html content is encoded using UTF-8
- The html contains a <meta> tag specifying the encoding as UTF-8
- This <meta> tag is paste the first 1024 bytes
Triggering the bug:
- Retrive a html page with a GET request and the afformentioned setup,
and the charset is detected as UTF-8
- Retrive the same page with a POST request and the afformentioned
setup, and the charset is detected as windows-1252
I know HTML5 specify that any encoding specification should lie in
completely in the first 1024 bytes, but it's not the case for any
previous (X)HTML specifications. In any case, this difference in
behavior between a GET and POST request is really puzzling. As far as I
tested, it happens both in strict mode (tested with xhtml 1.1 page) and
in quirk mode.
Here I join a test-case that includes a line of php to ensure the right
Content-Type header is sent, a large block of comment to put the <meta>
tag after the 1024 first bytes, an UTF-8 accented letter, a form with a
POST method.
The size of the comment block is so that removing one byte make the bug
go away.
Best regards,
Celelibi