3 ms·
I would say the opposite: putting critical information only in HTTP headers is dangerous; always put it in the actual file; in some cases a file extension is su
by o11c 2y ago
I would say the opposite: putting critical information only in HTTP headers is dangerous; always put it in the actual file; in some cases a file extension is sufficient.
- csande17 2y agoIf you do want to ensure the file is interpreted as UTF-8 regardless of HTTP headers, the most efficient way is to place a U+FEFF "byte order mark" character (EF BB BF when encoded as UTF-8) at the start of the file. It's shorter than a meta tag, and it's the first thing browsers check for when loading a file (assuming they're following https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding https://html.spec.whatwg.org/multipage/parsing.html#determin...).
- threatofrain 2y agoCould you explain the danger a little bit?
- o11c 2y agoChanging the encoding changes the meaning. If the encoding is only declared in a form that is easily lost during a standard action (downloading a file), that's bad.