Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

ძიება მხარდაჭერაში

ნუ გაებმებით თაღლითების მახეში მხარდაჭერის საიტზე. აქ არასდროს მოგთხოვენ სატელეფონო ნომერზე დარეკვას, შეტყობინების გამოგზავნას ან პირადი მონაცემების გაზიარებას. გთხოვთ, გვაცნობოთ რამე საეჭვოს შემჩნევისას „დარღვევაზე მოხსენების“ მეშვეობით.

Learn More

HTML page content type has charset=iso-8859-1 but document.characterSet is 'UTF-8'

  • 2 პასუხი
  • 2 მომხმარებელი წააწყდა მსგავს სიძნელეს
  • 5 ნახვა
  • ბოლოს გამოეხმაურა gilles.poirot

Hi,

I'm a web developer and I have an issue document.characterSet property from DOM API has an incorrect value on a non UTF-8 page

Firefox version: 95.0.2

1. HTML page is returned with following content-type content-type: text/html; charset=iso-8859-1

2. JavaScript code in the page reads document.characterSet property

Expected characterSet value is "ISO-8859-1"

Actual characterSet value is "UTF-8"

Thanks and regards,

Hi, I'm a web developer and I have an issue document.characterSet property from DOM API has an incorrect value on a non UTF-8 page Firefox version: 95.0.2 1. HTML page is returned with following content-type content-type: text/html; charset=iso-8859-1 2. JavaScript code in the page reads document.characterSet property Expected characterSet value is "ISO-8859-1" Actual characterSet value is "UTF-8" Thanks and regards,

ყველა პასუხი (2)

What encoding does the server send ?

If the server sends encoding "UTF-8" then that prevails and Firefox ignores a possible specification in the actual file for security reasons.

I observed this behavior while working on a customer incident. The server responds with a content-type header which is "text/html; charset=iso-8859-1"

I tried to reproduce on a sample but in my test, I get the expected "window-1252".

However, if the response body contains an UTF-8 BOM, content-type header is ignored and document characterSet is "UTF-8"

Here is a small sample https://glitch.com/edit/#!/document-charset

Is this the intended behavior?