Closed Bug 1776483 Opened 3 years ago Closed 3 years ago

Exclude folders starting with a symbol when loading the locales

Categories

(WebExtensions :: General, defect)

Desktop
All
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: sdk, Assigned: sdk)

Details

STR

  1. Open Firefox
  2. Go to about:debugging > This Firefox > Load Temporary Add-on
  3. Select a manifest.json

Description

If the _locales folder contains a folder starting with a dot, the addon will fail to load. This is because the current code wrongly assume that every folder use a name matching a locales code. However, this may not be the case.

Possible solution

  1. Match locales against a list of predetermined locales.
  2. We could detect with a regular expression if the folder name is a valid locale code before loading its content. For example:
  async _promiseLocaleMap() {
    let locales = new Map();

    let entries = await this._readDirectory("_locales", true);
    for (let name of entries) {
      let pattern = new RegExp(/* Match locales code pattern */);
      let locale = this.normalizeLocaleCode(name);

      if (locale.match(pattern)) {
        locales.set(locale, name);
      }
    }

    return locales;
  }
Assignee: nobody → contact

(In reply to Danny Colin [:sdk] from comment #0)

If the _locales folder contains a folder starting with a dot, the addon will fail to load. This is because the current code wrongly assume that every folder use a name matching a locales code. However, this may not be the case.

It doesn't assume this, it requires it. The _locales folder is special, and is only meant to contain locale data. Why do you need it to contain something else?

Why do you need it to contain something else?

For Multi-Account Containers, we have a separated git repository for the locales that we load in the main one as a submodule (See https://github.com/mozilla-l10n/multi-account-containers-l10n/). Since it's a git repository as any other on GItHub, it contains folders like .github/. This makes the loading of the addon fail.

We will not be doing this in Firefox for all extensions, developers can include removing this in their build step.

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