Closed Bug 1900703 Opened 1 year ago Closed 1 year ago

policies.json file fails to load if file encoding is utf-16le

Categories

(Firefox :: Enterprise Policies, defect, P5)

Firefox 126
defect

Tracking

()

RESOLVED WONTFIX

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:

  1. It should successfully load UTF-16LE encoded files.
  2. It should detect and display a dedicated error if the file is not UTF-8 encoded.
  3. The documentation for policies.json should explicitly clarify that only UTF-8 encoded files are supported.

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.

Component: Untriaged → Internationalization
Product: Firefox → Core

Seth, please attach policies.json.

Flags: needinfo?(seth)
Attached file policies.json

A UTF16-LE encoded policies.json file.

Flags: needinfo?(seth)

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.

DevTool?

Component: Internationalization → JSON Viewer
Product: Core → DevTools

I implemented this in the past, but was told to remove it. See bug 1396286 comment 23 and below.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1396286
Resolution: --- → DUPLICATE

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.

OK, wrong component then.

Status: RESOLVED → REOPENED
Component: JSON Viewer → Enterprise Policies
No longer duplicate of bug: 1396286
Ever confirmed: true
Product: DevTools → Firefox
Resolution: DUPLICATE → ---

Weird. When this was written, it used a function called "readUTF8File".

Clearly that's wrong.

Severity: -- → S4
Status: REOPENED → NEW
Priority: -- → P5

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.

Status: NEW → RESOLVED
Closed: 1 year ago1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: