policies.json file fails to load if file encoding is utf-16le
Categories
(Firefox :: Enterprise Policies, defect, P5)
Tracking
()
People
(Reporter: seth, Unassigned)
Details
Attachments
(1 file)
774 bytes,
application/json
|
Details |
Steps to reproduce:
I created a policies.json
file on a Windows machine, and used Notepad to create the file. Notepad creates files with a file encoding of UTF-16LE by default.
Operating System: Windows 10
Firefox version: 126.0.1 (64-bit)
Actual results:
Firefox failed to load the policies.json
file. It shows errors that JSON.parse
hit an unexpected character at line 1 column 1.
I was able to work around the issue by doing Save As in Notepad and saving the file as UTF-8 instead.
Expected results:
One of the following:
- It should successfully load UTF-16LE encoded files.
- It should detect and display a dedicated error if the file is not UTF-8 encoded.
- The documentation for policies.json should explicitly clarify that only UTF-8 encoded files are supported.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Internationalization' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
You'll find that in the preview the JSON appears to be malformed. That's actually the browser reading the file as UTF-8 instead of UTF-16LE.
If you download the file and run file -bi policies.json
, it will show the correct file encoding. It will also open fine in software like Visual Studio Code that handles file encoding.
The preview works correctly in Chromium, where it correctly treats it as valid JSON and offers to collapse or pretty-print it as normal.
Comment 5•1 year ago
|
||
DevTool?
Comment 6•1 year ago
|
||
I implemented this in the past, but was told to remove it. See bug 1396286 comment 23 and below.
This isn't a duplicate.
This is about the policies.json
file, and has little to do with the JSON Viewer or the HTML spec. It's the config of Firefox policy management, which fails to parse and doesn't give a helpful error to the user.
I'm not proposing that UTF-16LE is supported across the browser, including over the network, but just that Firefox should be able to read its own config files, and report errors accurately.
Comment 8•1 year ago
|
||
OK, wrong component then.
Comment 9•1 year ago
|
||
Weird. When this was written, it used a function called "readUTF8File".
Clearly that's wrong.
Comment 10•1 year ago
|
||
So upon further discussion with the team, I'm going to close this as WONTFIX and mark this as a restriction on our documentation.
policies.json is on a startup path and the function readUTF8File is highly optimized for startup.
So unfortunately doing any sort of encoding checking is not practical.
Description
•