Open Bug 1827656 Opened 2 years ago Updated 6 months ago

Warn or reject when moz-extension:-URL in temporary extension is invalid when packed as xpi

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

Details

(Whiteboard: [addons-jira])

When an extension is loaded temporarily from the local filesystem, paths are resolved according to the rules of the local filesystem. This can result in bugs being unnoticed, e.g. in the following scenarios (test cases below):

  • On the local filesystem, consecutive / are collapsed to one. When loaded from a xpi, this normalization does not happen. Example: bug 1817021
  • XPI files are case-sensitive, but a local filesystem can be case-insensitive (e.g. commonly on Windows, but FAT-formatted USB sticks could be case-insensitive too).

As a result, someone could develop and test that their extension is working, but then encounter failures to load moz-extension:-resources after the extension is packed.

To avoid this issue, we should verify whether the URL would be a valid URL, e.g. somewhere near https://searchfox.org/mozilla-central/rev/5f10809bf5559e6e988e4d1a58ce1338d391cc5f/netwerk/protocol/res/ExtensionProtocolHandler.cpp#957-966

Test case for / normalization

  1. Download any extension, unzip it and load it via about:debugging (or web-ext run).
  2. Click on the manifest.json link of the extension at about:debugging, and change /manifest.json to ///manifest.json
  3. If this is done for a packed extension, the resulting file is not found.
  4. When done for a temporarily loaded extension, the resulting file is found.

Test case for case-insensitive file.

  1. Download any extension, unzip it to a case-insensitive filesystem, and load it via about:debugging (or web-ext run).
  2. Click on the manifest.json link of the extension at about:debugging, and change /manifest.json to /MANIFEST.json
  3. If this is done for a packed extension, the resulting file is not found.
  4. When done for a temporarily loaded extension, the resulting file is found.

On Linux, the filesystem is typicaly case-sensitive. Here is a way to create a case-insensitive filesystem:

$ dd if=/dev/zero of=disk.fat bs=1M count=10
$ sudo mkdir /mnt/fatdisk
$ sudo mount virtual.dsk /mnt/fatdisk -t vfat -o loop,rw,user,uid=$UID,gid=$GROUP
$ cd /mnt/fatdisk

$ # Download an example extension and extract it:

$ wget https://addons.mozilla.org/firefox/downloads/file/3590576/open_bookmark_in_container_tab-1.3.xpi
$ unzip open_bookmark_in_container_tab-1.3.xpi
Duplicate of this bug: 1817021
Severity: -- → N/A
Priority: -- → P3
Whiteboard: [addons-jira]
See Also: → 1880735
See Also: → 1938662
You need to log in before you can comment on or make changes to this bug.